History log of /netbsd-current/tests/usr.bin/xlint/lint1/Makefile
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.142 08-Jun-2024 rillig

tests/lint: reorganize tests

Tests for a single working language construct don't usually need a
separate file, they can be grouped together, like in expr.c or gcc.c.


# 1.141 23-Apr-2023 rillig

tests/lint: test command line parsing for message and query IDs

The parsing methods differ but shouldn't.


# 1.140 05-Feb-2023 rillig

tests/lint: fix source directory for looking up the .exp-ln files


# 1.139 05-Feb-2023 rillig

tests/lint1: the redundantly listed files contained .exp-ln as well


# 1.138 05-Feb-2023 rillig

tests/lint: fix resolving of wildcards in builds from other directories


# 1.137 05-Feb-2023 rillig

tests/lint: remove redundancy from Makefile

The list of test files is already kept in distrib/sets/lists/tests/mi.


# 1.136 05-Feb-2023 rillig

tests/lint: remove redundant tests

The names of the tests were misleading: 'recursive' should have been
'nested', and the interesting topic in the 'cast' tests was not the cast
but the pointer dereference.


# 1.135 29-Jan-2023 rillig

tests/lint: merge tests for '>>'


# 1.134 22-Jan-2023 rillig

tests/lint: merge tests for declaration after statement


# 1.133 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.132 21-Jan-2023 rillig

tests/lint: test _Atomic, added in C11


# 1.131 15-Jan-2023 rillig

tests/lint: add test for parsing sizeof expressions


# 1.130 04-Jan-2023 rillig

tests/lint: merge tests for ':?' with null pointer constant


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.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-8-3-RELEASE 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-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.141 23-Apr-2023 rillig

tests/lint: test command line parsing for message and query IDs

The parsing methods differ but shouldn't.


# 1.140 05-Feb-2023 rillig

tests/lint: fix source directory for looking up the .exp-ln files


# 1.139 05-Feb-2023 rillig

tests/lint1: the redundantly listed files contained .exp-ln as well


# 1.138 05-Feb-2023 rillig

tests/lint: fix resolving of wildcards in builds from other directories


# 1.137 05-Feb-2023 rillig

tests/lint: remove redundancy from Makefile

The list of test files is already kept in distrib/sets/lists/tests/mi.


# 1.136 05-Feb-2023 rillig

tests/lint: remove redundant tests

The names of the tests were misleading: 'recursive' should have been
'nested', and the interesting topic in the 'cast' tests was not the cast
but the pointer dereference.


# 1.135 29-Jan-2023 rillig

tests/lint: merge tests for '>>'


# 1.134 22-Jan-2023 rillig

tests/lint: merge tests for declaration after statement


# 1.133 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.132 21-Jan-2023 rillig

tests/lint: test _Atomic, added in C11


# 1.131 15-Jan-2023 rillig

tests/lint: add test for parsing sizeof expressions


# 1.130 04-Jan-2023 rillig

tests/lint: merge tests for ':?' with null pointer constant


Revision tags: netbsd-10-base
# 1.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


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-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.140 05-Feb-2023 rillig

tests/lint: fix source directory for looking up the .exp-ln files


# 1.139 05-Feb-2023 rillig

tests/lint1: the redundantly listed files contained .exp-ln as well


# 1.138 05-Feb-2023 rillig

tests/lint: fix resolving of wildcards in builds from other directories


# 1.137 05-Feb-2023 rillig

tests/lint: remove redundancy from Makefile

The list of test files is already kept in distrib/sets/lists/tests/mi.


# 1.136 05-Feb-2023 rillig

tests/lint: remove redundant tests

The names of the tests were misleading: 'recursive' should have been
'nested', and the interesting topic in the 'cast' tests was not the cast
but the pointer dereference.


# 1.135 29-Jan-2023 rillig

tests/lint: merge tests for '>>'


# 1.134 22-Jan-2023 rillig

tests/lint: merge tests for declaration after statement


# 1.133 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.132 21-Jan-2023 rillig

tests/lint: test _Atomic, added in C11


# 1.131 15-Jan-2023 rillig

tests/lint: add test for parsing sizeof expressions


# 1.130 04-Jan-2023 rillig

tests/lint: merge tests for ':?' with null pointer constant


Revision tags: netbsd-10-base
# 1.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


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-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.135 29-Jan-2023 rillig

tests/lint: merge tests for '>>'


# 1.134 22-Jan-2023 rillig

tests/lint: merge tests for declaration after statement


# 1.133 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.132 21-Jan-2023 rillig

tests/lint: test _Atomic, added in C11


# 1.131 15-Jan-2023 rillig

tests/lint: add test for parsing sizeof expressions


# 1.130 04-Jan-2023 rillig

tests/lint: merge tests for ':?' with null pointer constant


Revision tags: netbsd-10-base
# 1.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


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-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.134 22-Jan-2023 rillig

tests/lint: merge tests for declaration after statement


# 1.133 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.132 21-Jan-2023 rillig

tests/lint: test _Atomic, added in C11


# 1.131 15-Jan-2023 rillig

tests/lint: add test for parsing sizeof expressions


# 1.130 04-Jan-2023 rillig

tests/lint: merge tests for ':?' with null pointer constant


Revision tags: netbsd-10-base
# 1.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


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-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.134 22-Jan-2023 rillig

tests/lint: merge tests for declaration after statement


# 1.133 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.132 21-Jan-2023 rillig

tests/lint: test _Atomic, added in C11


# 1.131 15-Jan-2023 rillig

tests/lint: add test for parsing sizeof expressions


# 1.130 04-Jan-2023 rillig

tests/lint: merge tests for ':?' with null pointer constant


Revision tags: netbsd-10-base
# 1.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


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-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.131 15-Jan-2023 rillig

tests/lint: add test for parsing sizeof expressions


# 1.130 04-Jan-2023 rillig

tests/lint: merge tests for ':?' with null pointer constant


Revision tags: netbsd-10-base
# 1.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


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-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.130 04-Jan-2023 rillig

tests/lint: merge tests for ':?' with null pointer constant


Revision tags: netbsd-10-base
# 1.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


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-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.129 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.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.128 17-Jun-2022 rillig

tests/lint: move check-expect.lua to tests/lint1

It is only used for testing lint1, not for lint2 or xlint.


# 1.127 17-Jun-2022 rillig

tests/lint: remove .exp files, as they have become redundant

Now that each lint1 test lists all generated diagnostics as 'expect'
comments, the information from the .exp files is no longer needed. The
only information that gets lost is the order of the diagnostics, which
is mostly relevant for paired messages like 'inconsistent definition' +
'previous definition was here'.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.126 16-Jun-2022 rillig

tests/lint: add more details to messages in msg_200 until msg_299

Add some tests that were previously empty. Some other tests are still
empty.


# 1.125 16-Jun-2022 rillig

tests/lint: make expectation lines in the tests more detailed

This commit migrates msg_100 until msg_199.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.124 10-Jun-2022 rillig

tests/lint: fix test for loss of accuracy on ILP32 platforms

The test had been wrong since msg_132.c 1.14 from 2022-05-30.

Using 'unsigned long' in a test that was intended to behave the same on
ILP32 and LP64 was an accident. Use 'unsigned long long' instead, which
is 64-bits wide on all platforms supported by lint.

Move the test about conversion from 'long' to 'int' to the
platform-specific test files.

Noticed by martin@ on powerpc.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.123 12-May-2022 rillig

tests/lint: add more tests for __alignof__


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.122 12-May-2022 rillig

tests/lint: adjust tests to reflect missing support of __alignof__

The change in lex.c 1.129 attempted to add support for __alignof, in
addition to the existing support for __alignof__. It failed by removing
support for __alignof__, while allowing the plain 'alignof' instead.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.121 28-Apr-2022 rillig

lint: revert resolving grammar conflicts for labeled statements

Restore the grammar rule for labeled_statement as it was before cgram.y
1.400 from 2022-04-24. This allows labels with attributes again. Fix
the wrong interpretation in the tests; the attributes belong to the
label, not to the statement.

Today in the morning, when I thought that the change in cgram.y 1.400
were innocent, I accidentally ran lint only with the options '-Sw' but
forgot the option '-g' for GNU mode. Without that option, the token
'__attribute__' is unknown, which unsurprisingly leads to lots of syntax
errors, and these didn't change with that commit. The actual change was
only visible in GNU mode.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.120 16-Apr-2022 rillig

lint: fix instructions for adding a new test


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.119 08-Apr-2022 rillig

lint: remove unused message 70, add some more tests


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.118 05-Apr-2022 rillig

tests/lint: add tests for a few early messages


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.117 20-Dec-2021 rillig

tests/lint: test excess braces around initializers


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.116 16-Dec-2021 rillig

tests/lint: remove generated shell program on 'make clean'


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.115 06-Dec-2021 rillig

tests/lint: demonstrate wrong warning for __builtin_alloca


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.114 30-Oct-2021 rillig

lint: warn if an enum name is used for mismatched array access

This helps to keep the enum definition and the straight-forward
implementation of a to_string or name function in sync.

The test for message 241 had to be adjusted because of exactly this bug.
That test defined a bit mask enum but accessed it like a value enum
type.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.113 26-Sep-2021 rillig

tests/lint: add tests for platform characteristics

Running lint in usr.bin/make on i386 fails due to this warning:

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]

This warning only occurred on i386 but not on sparc or x86_64. Try to
reproduce the test situation in platform_int.

The platform code in t_integration.sh was not strict enough, it didn't
check for multiple conditions, such as in msg_132_ilp32. That test was
only supposed to run on ILP32 platforms where size_t is unsigned int. It
also ran on sparc, even though size_t is long there.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.112 13-Sep-2021 rillig

tests/lint: add more tests for direct-abstract-declarator

Lint's grammar in this area differs a lot from the grammar in C99. GCC's
parser has a long comment about special cases in this area. It's tricky
to even parse these type names correctly, let alone assign them the
correct types, that's why it needs more tests before trying to refactor
that code.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.111 12-Sep-2021 rillig

lint: add more details to error about redeclaration

Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.110 10-Sep-2021 rillig

tests/lint: test line number tracking with \v and \f


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.109 03-Sep-2021 rillig

tests/lint: test GCC builtins for overflow in strict bool mode

Seen in inetd.c.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.108 31-Aug-2021 rillig

tests/lint: add test for prototype conversions in C90

The purpose of warning 259 is to find function calls that differ in the
ABI. The warning's original purpose was not to warn about lossy
conversions, that's just a side effect.

Warning 259 had been implemented before C99 was published, which is more
than 20 years ago. In the meantime, almost all code has migrated to
using function prototypes. With the default lint flags from NetBSD's
<sys.mk>, it would rather make sense to focus on lossy conversions now.

To prepare for potentially upcoming differences in lint's C90 and C99
modes, clone the test now as far as possible. The test for C90 mode is
smaller than for C99 mode, since 'long long' was not available back
then.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.107 25-Aug-2021 rillig

tests/lint: test conversion from long long to intptr_t on ilp32

Seen in usr.bin/make/var.c:1608.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.106 22-Aug-2021 rillig

tests/lint: demonstrate wrong constant folding in strict bool mode

Found while investigating wrong constant folding in default mode.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.105 19-Aug-2021 rillig

tests/lint: test folding of constant expressions

Since November 2001, there is a comment above the function 'fold' that
suggests there are a few bugs concerning overflow detection. Add some
first 'proper regression tests' to prove these bugs.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.104 16-Aug-2021 rillig

tests/lint: test arithmetic promotions and enums


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.103 09-Aug-2021 rillig

lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.102 05-Aug-2021 rillig

tests/lint: test emitting 128-bit integer types for lint2


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.101 03-Aug-2021 rillig

tests/lint: test GCC extension for casting to union type


# 1.100 03-Aug-2021 rillig

tests/lint: test casting a struct to another struct


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.99 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions in traditional C


# 1.98 01-Aug-2021 rillig

tests/lint: test the usual arithmetic conversions

The function 'balance' does not mention __uint128_t and nevertheless
works as expected. Need to investigate further.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.97 25-Jul-2021 rillig

tests/lint: cover every code line in the grammar


# 1.96 25-Jul-2021 rillig

tests/lint: test declarators with attributes


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.95 25-Jul-2021 rillig

tests/lint: demonstrate missing support for GCC typeof


# 1.94 25-Jul-2021 rillig

tests/lint: test parse errors in statements

These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.

The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.


# 1.93 25-Jul-2021 rillig

tests/lint: test parsing of type_name


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.92 15-Jul-2021 rillig

tests/lint: cover more edge cases in the parser


# 1.91 15-Jul-2021 rillig

tests/lint: test struct declarations


# 1.90 15-Jul-2021 rillig

tests/lint: test precedence of operators


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.89 14-Jul-2021 rillig

tests/lint: add several tests for edge cases in the grammar


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.88 13-Jul-2021 rillig

tests/lint: test binary integer literals and underscores


# 1.87 13-Jul-2021 rillig

tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.86 11-Jul-2021 rillig

lint: support __attribute__((hot))

The corresponding attribute 'cold' was already added in cgram.y 1.84
from 2016-12-29.


# 1.85 11-Jul-2021 rillig

tests/lint: test dangling else


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.84 10-Jul-2021 rillig

tests/lint: test declarations


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.83 10-Jul-2021 rillig

tests/lint: add more tests for covering the grammar


# 1.82 09-Jul-2021 rillig

tests/lint: add test for unrealistic edge cases in declarations

The example code for triggering these grammar rules looks completely
contrived. Even if lint had not implemented these cases, hopefully
nobody would have ever noticed.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.81 08-Jul-2021 rillig

tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests. The
untested parts are mostly obscure declarations and a few parse errors.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.80 06-Jul-2021 rillig

tests/lint: add tests for GCC __attribute__

Before fixing the wrong handling of __attribute__ that is demonstrated
at the end of gcc_attribute.c, ensure that the attribute handling works
in the most basic cases.

Lint currently accepts __attribute__ in more places than it should.
This leads to some ambiguities in the grammar.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.79 04-Jul-2021 rillig

test/lint: demonstrate wrong warnings for 128-bit shifts


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.78 04-Jul-2021 rillig

lint: remove remaining support for lvalue casts

These had been GCC extensions until GCC 3.4, they were removed in GCC
4.0.


# 1.77 04-Jul-2021 rillig

tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


# 1.76 04-Jul-2021 rillig

lint: remove outdated assertion

Since err.c 1.12 from 2000-07-06, lint allows to suppress individual
error messages. Suppressed error messages do not increment nerr.
Keeping nerr at 0 had triggered the assertion.


# 1.75 04-Jul-2021 rillig

tests/lint: add test for suppressing errors in strict bool mode


# 1.74 03-Jul-2021 rillig

tests/lint: fix test for character comparison on macppc

On macppc, char == unsigned char, which generates one more warning than
on platforms where char == signed char.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.73 02-Jul-2021 rillig

tests/lint: add test for array subscripts in C99 initialization


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.72 29-Jun-2021 rillig

lint: fix wrong warning about out-of-range value '\xff' for char

This only affects platforms where char has the same representation as
unsigned char.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.71 29-Jun-2021 rillig

tests/lint: add test that only runs where char == unsigned char

There a 4 regular NetBSD builds where lint is activated. All these
builds run on platforms where char == signed char.

The official test runs from https://releng.netbsd.org/test-results.html
mostly have char == signed char as well.

However, lint behaves differently on platforms with char == unsigned
char. On these platforms, a simple "char ch = '\xff'" leads to the
bogus warning that "conversion of 'int' to 'char' is out of range".


# 1.70 29-Jun-2021 rillig

tests/lint: add 'make accept' to update the expected output


# 1.69 29-Jun-2021 rillig

tests/lint: add tests for ILP32 platforms

Previously, all tests for lint had to produce the exact same output, no
matter which platform they ran on. This differs from practical needs
since lint is intended to produce different results depending on whether
the platform is ILP32 or LP64.

Examples for these are type conversions and the widths of the integer
types during lexical analysis.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.68 27-Jun-2021 rillig

lint: require C11 for _Generic

This does not have any effect in practice since the option -g
(originally meant for GCC extensions to the C standards) implicitly
allows all features from C11, since err.c 1.111 from 2021-04-14.

Since the default lint flags for NetBSD builds include the option -g,
this allows all C11 features.

Currently it is not possible to say "allow GNU extensions but not C11".


# 1.67 27-Jun-2021 rillig

lint: fix option -Ac11, add test for _Generic

Previously, selecting the option -Ac11 allowed features from C11 but at
the same time prohibited 'long long', which was added in C99. This was
caused by the option -s, which is interpreted as "allow features from
C90, but no later".

The test for _Generic, which has been added in C11, demonstrates that
the current implementation is broken. Lint currently thinks that the
return type of a _Generic selection is the type of the expression, but
it really is the type of the selected expression. In the current tests,
this is always 'const char *', but C11 does not require that the types
of a generic selection are compatible.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.66 27-Jun-2021 rillig

tests/lint: rename expected .ln file to .exp-ln

This way, the hack for suffixes is no longer needed.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.65 20-Jun-2021 rillig

tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.64 19-Jun-2021 rillig

lint: fix endless loop on unfinished comment at EOF

Found using afl.


# 1.63 19-Jun-2021 rillig

lint: fix assertion after malformed for loop

Found using afl.


# 1.62 19-Jun-2021 rillig

lint: fix assertion failure in struct with unnamed member

Found using afl.


# 1.61 19-Jun-2021 rillig

lint: fix crash in malformed initialization


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.60 19-Jun-2021 rillig

tests/lint: add test cases for lexical analysis


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

branches: 1.55.2;
tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.59 25-May-2021 rillig

tests/lint: make test d_gcc_extension platform-independent

That test was intended to test the keywords '__extension__' and
'__typeof'. The GCC builtin functions were just a side-effect.

These built-in functions generated error messages on platforms such as
amd64 where sizeof(long double) != sizeof(double), but not on others
such as sparc.

The current infrastructure for the lint tests cannot handle tests with
platform-dependent outcome.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.58 16-May-2021 rillig

lint: add more specific warning for bit-field of type plain 'int'

Previously, declaring a bit-field of type plain 'int' resulted in this
warning:

warning: nonportable bit-field type 'int' [34]

This warning was too unspecific to be actionable, and until yesterday it
didn't even include the type. In order to allow this warning to be
understood and properly fixed, describe the actual nonportability more
precisely:

warning: bit-field of type plain 'int' has
implementation-defined signedness [344]


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


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.56 14-May-2021 rillig

tests/lint: test bitwise mismatch in switch statement


Revision tags: cjep_staticlib_x-base
# 1.55 02-May-2021 rillig

tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.55 02-May-2021 rillig

tests/lint: add test for bit-field types in GCC mode


# 1.54 02-May-2021 rillig

tests/lint: demonstrate missing support for __packed __aligned


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.53 30-Apr-2021 rillig

tests/lint: add very basic tests for GCC __attribute__


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.52 22-Apr-2021 rillig

tests/lint: add test for typeof after statement

Found by christos@.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.51 21-Apr-2021 christos

Put things back, emit.ln it was meant to be there.


# 1.50 21-Apr-2021 christos

remove emit.ln; looks like an accident and breaks the build.


# 1.49 21-Apr-2021 rillig

tests/lint: fix the hack for emit.ln to also work if MKUPDATE != "no"


# 1.48 20-Apr-2021 rillig

tests/lint: fix inconsistent operator for emit.ln

The build failed with:

nbmake[8]: "/.../src/share/mk/bsd.files.mk" line 47:
Inconsistent operator for /.../emit.ln


# 1.47 20-Apr-2021 rillig

tests/lint1: fix build error "must name an existing directory"

The build failed with this error message:

x86_64--netbsd-install: the last argument (/.../emit.ln) must
name an existing directory

The cause for this message was that ${DESTDIR}/.../emit.ln has
${DESTDIR}/.../emit.c as implicit target, which is kind of correct but
unintended in this case. Because of this, the command 'install' was run
like this:

install ${NETBSDSRCDIR}/.../emit.ln ${DESTDIR}/.../emit.c \
${DESTDIR}/.../emit.ln


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.46 18-Apr-2021 rillig

tests/lint: record all files from FILES in distrib/sets/lists/tests/mi


# 1.45 18-Apr-2021 rillig

tests/lint: add emit.ln to the release files


# 1.44 18-Apr-2021 rillig

lint: test emitting of symbol information in the .ln files

Even though the new test is quite large, it didn't find any bugs in the
code. The only thing I'm unsure about is why static functions are
exported as well, since they are supposed to be local to the translation
unit.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.43 17-Apr-2021 rillig

tests/lint: demonstrate assertion failure in initialization


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.42 14-Apr-2021 rillig

lint: add test for newly added message about static array size


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.41 09-Apr-2021 rillig

tests/lint: demonstrate wrong lint warning about complex variables


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.40 08-Apr-2021 rillig

lint: in code from included files, print stack trace

Previously, the standard NetBSD build generated several lint warnings in
lhash.h from OpenSSL, without providing any hint as to which file
actually included that header. In cases like these, lint now interprets
the line number information in the preprocessor output from GCC to
reconstruct the exact include path to the file in question.

The program check-expect.lua had to be rewritten almost completely since
it assumed that all diagnostics would come from the main file. In all
existing tests, this was true, but these tests did not cover all cases
that occurred in practice. Now it records the complete location of the
diagnostic instead of just the line number.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.39 05-Apr-2021 rillig

lint: warn about for wrong type cast in argument to ctype.h functions

The argument to most of the functions from <ctype.h> "shall either be
representable as an 'unsigned char' or shall equal the value of the
macro EOF".

When confronted with the infamous warning 'array subscript has type
char', there are enough programmers who don't know the background of
that warning and thus fix it in a wrong way. Neither GCC nor Clang
explain its warning to target these programmers.

Both GCC and Clang warn about 'array subscript has type char', but they
ignore the other requirements of the <ctype.h> functions, even though
these are in the C standard library.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94182
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95177
https://stackoverflow.com/a/60696378


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.38 02-Apr-2021 rillig

tests/lint: prevent typo from tree.c 1.264 from happening again


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.37 28-Mar-2021 rillig

lint: remove wrong warning about wrong initializer type

The following code is valid:

int valid = {{{ 3 }}};

C90 3.5.7 and C99 6.7.8 both say that the "initializer for a scalar
shall be a single expression, optionally enclosed in braces". They
don't put any upper bound on the amount of braces, not even in the
"Translation limits" section.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.36 23-Mar-2021 rillig

tests/lint: test initialization using string literals

The errors in line 74 and 75 of the test are wrong. Everything is fine
there. The bug lies in init_array_using_string, try to see if you can
spot it, neither GCC 9.3.0 nor Clang 8.0.1 could.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.35 07-Mar-2021 rillig

lint: in strict C mode, warn about initialization with '[a ... b]'

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


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.34 28-Feb-2021 rillig

lint: fix null pointer dereference on parse error

Fixes PR bin/22119.


# 1.33 28-Feb-2021 rillig

lint: add test to demonstrate that PR bin/20264 has been fixed


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.32 21-Feb-2021 rillig

lint: add another test for C99 initializers


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.31 19-Feb-2021 rillig

lint: warn about mismatch in getopt handling


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.30 17-Jan-2021 rillig

lint: add more tests for system headers in strict bool mode


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.29 14-Jan-2021 rillig

lint: add tests for newly added messages for strict bool mode


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.28 10-Jan-2021 rillig

lint: add test for triggering assertion failures in lint1


# 1.27 10-Jan-2021 rillig

lint: add test for treating _Bool as non-scalar type

This strict mode is not yet implemented. The plan is to use it for
usr.bin/make, to get rid of the many possible variants of defining the
Boolean type in make.h. These variants did find some bugs, but not
reliably so. Using static analysis seems more promising for this.

In an early stage of developing this test, lint1 crashed in the enum
definition in line 213, where the node for the '?:' had been NULL. This
can happen in other situations as well, such as with syntax errors, but
these should be rare, as lint is usually only run if the compiler has
accepted the source code. Still, there should not be any assertion
failures while running lint1.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.26 10-Jan-2021 rillig

lint: demonstrate wrong handling of conversion to _Bool


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.25 02-Jan-2021 rillig

lint: add a test for each message produced by lint1

Having a test for each message ensures that upcoming refactorings don't
break the basic functionality. Adding the tests will also discover
previously unknown bugs in lint.

The tests ensure that every lint message can actually be triggered, and
they demonstrate how to do so. Having a separate file for each test
leaves enough space for documenting historical anecdotes, rationale or
edge cases, keeping them away from the source code.

The interesting details of this commit are in Makefile and
t_integration.sh. All other files are just auto-generated.

When running the tests as part of ATF, they are packed together as a
single test case. Conceptually, it would have been better to have each
test as a separate test case, but ATF quickly becomes very slow as soon
as a test program defines too many test cases, and 50 is already too
many. The time complexity is O(n^2), not O(n) as one would expect.
It's the same problem as in tests/usr.bin/make, which has over 300 test
cases as well.


# 1.24 01-Jan-2021 rillig

lint: demonstrate bug in handling of nested C9X struct initializers


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.23 01-Jan-2021 rillig

lint: fix segmentation fault when checking returned enum types (211)


# 1.22 31-Dec-2020 rillig

lint: check that in "if (cond)", cond is scalar


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.21 30-Dec-2020 rillig

lint: add test for old style function arguments


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.20 28-Dec-2020 rillig

lint1: add forgotten tests


# 1.19 28-Dec-2020 rillig

lint1: enable test cvt_constant

This test had never been enabled. In t_integration.sh 1.3 from
2014-04-17 it was supposed to be enabled, but due to a line continuation
backslash, the words "test_case check_valid" ended up as the description
of the previous test, cvt_in_ternary.

While here, add the expected test output for d_struct_init_nested to
FILES.


# 1.18 28-Dec-2020 rillig

lint1: add test for initializing nested structs

Discovered in var.c 1.774 from 2020-12-28.


# 1.17 28-Dec-2020 rillig

lint: for tests with output, ensure that the output matches


# 1.16 28-Dec-2020 rillig

lint: sort tests by name


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 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
# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

branches: 1.13.2;
Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

branches: 1.11.2;
Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


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 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


# 1.15 06-Mar-2017 christos

add builtin_offsetof


# 1.14 06-Mar-2017 christos

add a test for a typeof cast


Revision tags: bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


Revision tags: netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.


Revision tags: pgoyette-localcount-20161104 localcount-20160914
# 1.13 19-Aug-2016 christos

Add union cast test


# 1.12 18-Aug-2016 christos

new test for struct that only has anon members, and that the size of struct
is computer right.


Revision tags: pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.11 14-Oct-2015 christos

Add an anonymous struct test


# 1.10 29-Jul-2015 christos

new test


# 1.9 28-Jul-2015 christos

new c99 init test found by xorg's Iconify.c


# 1.8 01-Jul-2015 christos

new test.


# 1.7 11-May-2015 christos

add one more test


# 1.6 03-Apr-2015 christos

add test for typename as a function param


# 1.5 20-Nov-2014 christos

test for c99 flexible packed arrays


# 1.4 20-Nov-2014 christos

Add one more test


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-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 yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.3 17-Apr-2014 christos

add more tests


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.2 04-Feb-2014 njoly

branches: 1.2.2;
Handle another declaration after statement case for lint in c99 mode.
Add the corresponding testcase.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.1 17-Mar-2012 jruoho

branches: 1.1.2; 1.1.4;
Deprecate tests/util.