Commit Graph

17768 Commits

Author SHA1 Message Date
rillig
381fecf673 lint: preserve curr_pos when checking whether a symbol is used
At the end of a function definition (funcend), curr_pos was not
restored, probably because the very next action is to read the next
token, which will then set curr_pos.

Again, this may affect the location reported in assertion failures,
everything else is unchanged.
2021-04-18 09:37:18 +00:00
rillig
7dcdec7722 lint: do not modify curr_pos in check_global_symbols
No functional change.
2021-04-18 09:20:43 +00:00
rillig
4dc66409e9 lint: in check_global_variable_size, restore curr_pos
This affects only calls to lint_assert, all other code stays
functionally the same.
2021-04-18 09:15:16 +00:00
rillig
b9784b3ffa lint: migrate check_tag_usage to warning_at
This one is already a little trickier since it does not restore the
original curr_pos.  This function is only called in a few places, and
these either restore curr_pos themselves or only call functions
afterwards that immediately overwrite curr_pos.

Except for lint_assert, which may now report a different location.

The call to check_global_variable that is related to check_tag_usage was
the function that started this whole refactoring since its lint_assert
reported a completely wrong location when using a compound literal in an
initializer expression at block level 0.
2021-04-18 09:07:36 +00:00
rillig
ef084fd475 lint: migrate print_previous_declaration to message_at 2021-04-18 08:57:57 +00:00
rillig
152aae6b2f lint: migrate the getopt check to warning_at 2021-04-18 08:53:35 +00:00
rillig
1052a4a017 lint: add error_at, warning_at, message_at
Right now there are several places in the code that use the global
variable curr_pos for passing a parameter to the diagnostic functions.
That's not what global variables are for.

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

No functional change.
2021-04-18 08:52:04 +00:00
rillig
48ee035ba0 lint: do not allow the diagnostics to be modified 2021-04-18 08:07:04 +00:00
rillig
1cf5b1560c lint: fix storage class of compound literal in initializer
A compound literal that occurs at block_level 0 does not have storage
class AUTO.  Instead, its storage class is either EXTERN or STATIC.

While removing the temporary objects from the symbol table had prevented
the assertion, it did not properly fix the underlying problem, which was
that since C99 the initializers can contain references to unnamed
objects that are created on-the-fly.  For C90 it was correct to always
use AUTO as the storage class of a temporary symbol.
2021-04-18 08:00:13 +00:00
rillig
73b70e7b0b lint: document wrong location information in diagnostics 2021-04-18 07:31:47 +00:00
rillig
0580bd7587 lint: fix assertion failure for temporary objects in initialization 2021-04-17 21:20:08 +00:00
rillig
c322b8c5b5 lint: do not warn about alignment when casting from incomplete struct
This removes a bunch of technically correct but practically useless
warnings from the regular NetBSD build.
2021-04-17 16:58:04 +00:00
rillig
3c425c406d lint1: remove redundant dependency
This is already handled by "make depend".
2021-04-17 11:01:34 +00:00
maya
5858bd6b8c Remove SCCS workarounds. No binary change. 2021-04-17 08:34:27 +00:00
maya
d8cc1107df Remove SCCS workarounds. No binary change. 2021-04-17 06:14:15 +00:00
christos
5f835dcadf appease gcc-9 2021-04-17 00:02:19 +00:00
christos
e598b150b9 PR/56112: Justin Parrott: Don't unlink a lock file without locking it, because
you can have races when multiple processes try to unlink it. Check the link
count to see if we have won the race.

While here:
- use snprintf
- use warn
- use size_t/ssize_t
- use loops instead of goto
- KNF
2021-04-16 22:41:12 +00:00
christos
4a8f7c3df0 make value an int to avoid all the casts and conversion warnings. 2021-04-16 18:31:28 +00:00
rillig
9e5a82eed4 make: use distinct wording for writing to the shell commands file
The word 'write' now means to write to the file that holds the shell
commands to be run later.

The word 'print' is now used exclusively for handling the output of the
child commands and printing them to make's stdout.

No functional change.
2021-04-16 16:49:27 +00:00
rillig
32bd955566 make: align name of jobs_table_dump to the other functions 2021-04-16 16:10:01 +00:00
christos
f1d025f4e1 Change octal and hex parsing to not use strtoul so that they don't handle
'-'. From Martijn van Duren.
Also add a warning if the conversion fails (like the gnu printf does)
2021-04-16 15:10:18 +00:00
rillig
87e1399e00 make: remove type name for the abort status in job handling 2021-04-15 19:06:42 +00:00
rillig
b089333f2a tests/make: demonstrate handling of null bytes 2021-04-15 19:02:29 +00:00
rillig
b1928e38b6 make: rename PrintOutput to PrintFilteredOutput to avoid confusion
In the default configuration, the function PrintOutput did nothing.
Only if the shell has defined an output filter, something happens at
all.
2021-04-15 18:36:17 +00:00
rillig
d11aa0ae3d make: document two previously unknown bugs in job mode 2021-04-15 18:21:27 +00:00
rillig
507ed84ad7 lint: remove stray semicolon from grammar, make empty rule visible
No functional change.
2021-04-14 22:08:28 +00:00
christos
4d60a3d6f9 there is also an optional type qualifier list in the array size 2021-04-14 21:20:21 +00:00
christos
268a84db7b gnu enables c11 extensions 2021-04-14 21:20:02 +00:00
rillig
9103e93ec9 lint: un-abbreviate code for passing options to cpp, lint1 and lint2
No functional change.
2021-04-14 20:35:31 +00:00
rillig
3874a90eb6 lint: add option to accept C11 features
The list of available letters for the command line options gets shorter
and shorter.  Most of the interesting letters are already used for some
warning categories.  Curiously, -A, -W and -E were all still available.

The option -A nicely matches the intention of the option, which is to
allow a certain set of language features.  To keep the option available
for further extensions, define -Ac11 as the currently only valid option
of that kind.  This allows straight-forward extension for C17 and future
language standards, as well as independent feature-sets.  The options -W
and -E may someday complement the -A option, using the allow/warn/error
categories.
2021-04-14 20:06:40 +00:00
rillig
c58b6a91cc lint: arrange options in the usage messages
* lowercase the word 'usage'
* group the preprocessor flags on a line of their own
* add missing closing ']' for '-X'
* properly indent the lines
2021-04-14 19:25:48 +00:00
rillig
08565001cc lint: remove redundant condition in update_location 2021-04-14 18:38:06 +00:00
rillig
67509c5839 lint: add support for C11-isms such as int[static 3] 2021-04-14 18:35:40 +00:00
rillig
6aa88d9625 lint: add test for newly added message about static array size 2021-04-14 18:27:11 +00:00
rillig
b40d5c12d2 make: let the compiler decide whether to inline string functions
On x86_64, this reduces the binary size by 2 kB.
2021-04-14 17:39:11 +00:00
rillig
56af7cb8e9 make: turn run-time string concatenation into compile-time
No functional change.
2021-04-14 17:24:48 +00:00
rillig
d6aef06ed9 make: remove unnecessary modifier ':U' for certain fixed expressions
No functional change, since the expression is evaluated using
VARE_WANTRES, not using VARE_UNDEFERR.
2021-04-14 17:20:48 +00:00
rillig
278b3755f7 make: reduce memory allocations in the modifiers ':D' and ':U' 2021-04-14 16:59:34 +00:00
rillig
e7ab8fe199 make: rename members of ModifyWord_LoopArgs
No functional change.
2021-04-14 16:12:26 +00:00
rillig
be9afdd585 make: clean up pattern flags for the modifiers ':S' and ':C'
No special handling is necessary for C90 since none of the struct
members is a const_member.

The prefix 'Var' is not necessary since this type does not apply to a
variable but only to a modifier.

No functional change.
2021-04-14 15:41:08 +00:00
christos
c5e4c84a3f support parsing c99's static class for array size expressions. 2021-04-14 13:34:08 +00:00
christos
72044c4d9b Allow type attributes after function pointer parameters 2021-04-13 22:22:02 +00:00
mrg
97b36aa771 more GCC 10 fixes.
mDNSResponder: another wrong return local address

dhcp: ignore a seemingly impossible stringop overflow

hpacel: avoid maybe uninitialised error that is wrong.

rsh: avoid impossible malloc(0)

udf: cast pointers through (uintptr_t) to fool invalid boundary checks
2021-04-13 06:25:48 +00:00
mrg
28fe3b2bee ensure that pointer is filled in when used upon return. 2021-04-13 03:09:42 +00:00
mrg
a96299c3e9 increase the size of a buffer by 1 byte.
i think GCC 10 is right here.
2021-04-13 02:07:35 +00:00
mrg
af153cbd78 properly terminate a string after strncpy(). 2021-04-13 01:38:04 +00:00
rillig
1bda87efba make: spell SysV in mixed case
No functional change.
2021-04-12 18:53:51 +00:00
rillig
36d6de73c9 make: reduce memory allocation and strlen calls in modifier ':from=to'
Previously, SysVMatch was quite verbose and felt like hand-optimized
assembler code, which made it difficult to discover the underlying idea
of the code.

All this code was replaced with two simple calls to Substring_HasPrefix
and Substring_HasSuffix.  Now that the operands of that modifier are no
longer passed as C strings, there is no need to collect all information
in a single scan through the word and the pattern.

It was not necessary to call Var_Subst unconditionally.  Calling it only
when the string contains a '$' saves another memory allocation and two
string copies (because of the Buf_DoneDataCompact).

No functional change.
2021-04-12 18:48:00 +00:00
rillig
8c934898f4 tests/make: fix test for modifier ':from=to'
I had forgotten to remove the single quotes, to produce a really empty
word.  Plus I had forgotten the modifier ':Q' for the result, which
meant that the single quotes did not show up in the output.
2021-04-12 16:09:57 +00:00
rillig
c0e41e6979 tests/make: add table test for the modifier ':from=to'
Just to prevent any accidental change in the upcoming refactoring to
reduce memory allocation in ApplyModifier_SysV.
2021-04-12 16:04:30 +00:00