Commit Graph

719 Commits

Author SHA1 Message Date
rillig
b48597d41d lint: clean up new_name_node
No functional change.
2021-03-20 21:08:09 +00:00
rillig
440cc62809 lint: move getopname over to tree.c
Except for the one use in print_tnode, the name of the operator is only
used in tree.c.

No functional change.
2021-03-20 20:56:58 +00:00
rillig
ea582d3e24 lint: remove redundant operator properties table
It's enough to have modtab, which describes the properties of the
various operators.  There is no need to have a second table imods that
holds the same content.  Rather make modtab constant as well.

The only possible functional change is that the names of the internal
operators 'no-op', '++', '--', 'real', 'imag' and 'case' may appear in
diagnostics, where previously lint invoked undefined behavior by passing
a null pointer for a '%s' conversion specifier.
2021-03-20 20:39:35 +00:00
rillig
d6f490fd83 lint: fix argument names and table headings for operator definitions
The abbreviations in the table of operator properties had been wrong
since ops.def 1.10 from 2021-01-12, when strict bool mode was added.  In
an earlier working draft, I had named that column 'takes_others' instead
of 'requires_bool', that's where the 'o' came from.

The names of the macro arguments had been wrong since op.h 1.11 from
2021-01-09, when the order of the columns changed and the macros were
not adjusted accordingly.  Since all the properties of the operator
table are uniform, this didn't result in any bugs, it was just confusing
for human readers.

Clang-tidy suggests to enclose the macro arguments in oper.c in
parentheses but that is not possible since the arguments are either
empty or 1, and the syntactical ambiguity of the '+ 0' being either a
unary or a binary operator is needed here.

No change to the resulting binary.
2021-03-20 20:15:37 +00:00
rillig
5019ab66ba lint: make lint's own code pass the strict bool mode
No functional change.
2021-03-20 19:33:25 +00:00
rillig
7ccd7b1468 lint: use macro for initializing keywords table
Since today, lint's strict bool mode requires initializers to have the
correct type.  The flags in kwtab are of type bool and were initialized
with an int, for brevity.  Keep the brevity and do the conversion from
int to bool in a macro.

By defining several macros for the different kinds of keywords, reduce
the clutter of having 2 additional zeroes per line.  The macros also
remove the redundancy and thereby the possible inconsistency of filling
the wrong fields since these depend on the token type.

No functional change.  The only change to the binary is due to the
changed line numbers in the calls to lint_assert.
2021-03-20 19:24:56 +00:00
rillig
6a451d6268 lint: inline access to type properties in check_bad_enum_operation
No functional change.
2021-03-20 18:38:25 +00:00
rillig
10736dfe07 lint: in strict bool mode, check initialization as well
C99 6.7.8p11 says for initialization that "the same type constraints and
conversions as for simple assignments apply", so actually apply them.
(I had just forgotten this "operator" when I first implemented strict
bool mode.)
2021-03-20 17:18:50 +00:00
rillig
87876a2355 lint: rename ftflg to seen_fallthrough
One less abbreviation to remember when reading the code.

No functional change.
2021-03-20 16:16:32 +00:00
rillig
73790b7671 lint: make the calls to clear_warning_flags stand out less
Even though clear_warning_flags and its companions are implemented as
macros, they act like ordinary functions.  Do not distract the reader by
using uppercase names for them.

No functional change.
2021-03-20 16:11:12 +00:00
rillig
f5c815bc77 lint: clean up grammar for declaration after statement
No functional change.
2021-03-20 15:30:58 +00:00
rillig
fb9b10bc8d lint: fix check for declaration after statement in pre-C99 mode
The new code may not be the most beautiful, but it fixes all bugs that
occurred while testing message 327.  The grammar rules are taken from
C99 6.8.2, so it's no surprise they work well.
2021-03-20 15:28:07 +00:00
rillig
daef7ea921 lint: properly name C99 in message about declaration after statement
Now that C99 has been released and published, there is no reason anymore
to refer to it as C9X.
2021-03-20 14:17:56 +00:00
rillig
b925668ec9 lint: use proper boolean literals instead of 0/1
The code in the C grammar is generated by yacc and is not checked by
lint's strict bool mode, therefore the replacement was done manually.

No change to the resulting change.
2021-03-20 13:53:28 +00:00
rillig
e4fa7e61a5 lint: update comment on setasm for C99
No functional change.
2021-03-20 13:25:31 +00:00
rillig
4f4415984d lint: reduce indentation and braces in merge_type_specifiers
No functional change.
2021-03-20 13:22:06 +00:00
rillig
e305d7be33 lint: extract adjusting of the storage class into separate function
No functional change.
2021-03-20 13:06:05 +00:00
rillig
1cf2c45884 lint: document the struct for declarations more precisely
No functional change.
2021-03-20 13:00:43 +00:00
rillig
d37415b4e9 lint: remove unnecessary '%prec T_COMMA' from grammar
My previous commit message was wrong in saying that the '%prec' was
necessary.  It is not necessary.

Most probably I misspelled the name of the grammar rule as opt_comma
instead of comma_opt, which would lead to the same number of conflicts
in the grammar plus a warning, but no build failure.
2021-03-20 11:33:50 +00:00
rillig
941875ba2d lint: join grammar rules for initialization
The '%prec T_COMMA' is necessary to avoid lots of parse errors in the
lint1 unit tests.  Curiously, further down in the grammar, for compound
literals, the '%prec T_COMMA' is not necessary, even though the context
looks very similar.

No functional change.
2021-03-20 11:24:49 +00:00
rillig
5f7e254669 lint: fix grammar for initialization
Previously, the grammar syntactically accepted the following code:

	int var = .member = 12345;

The designation '.member =' can only be used with brace-enclosed
initializers.
2021-03-20 11:05:16 +00:00
rillig
b61f069794 lint: align rule names in grammar with C99
No functional change.
2021-03-20 10:32:43 +00:00
rillig
80b7b20b36 lint: fix assertion failure after error in designation
In d_c99_init.c, the initialization of array_with_designator failed.
The designator '.member' from that initialization was not cleaned up
before starting the next initialization.
2021-03-20 08:54:27 +00:00
rillig
88e315e145 lint: replace segmentation fault with assertion failure 2021-03-20 08:16:30 +00:00
rillig
1a007aec0b lint: improve debug loggin for initialization 2021-03-19 18:17:46 +00:00
rillig
a8fb7d4818 lint: rename designator_pop_name to designator_shift_name
The entries are removed from the beginning, not from the end.

No functional change.
2021-03-19 17:37:57 +00:00
rillig
4c27df2433 lint: use standard form of statement macro for debug_node
No functional change.
2021-03-19 08:23:39 +00:00
rillig
5acb533d3d lint: rename in_bit to in_bits
No functional change.
2021-03-19 08:21:26 +00:00
rillig
527774e33b lint: rename tsize to type_size_in_bits
The shorter name size_in_bits was already taken by the function-like
macro with argument type tspec_t.

No functional change.
2021-03-19 08:19:24 +00:00
rillig
19ff95ceea lint: add reminder that C99 does not allow '{}' in initializer
No functional change.
2021-03-19 07:54:13 +00:00
rillig
0b45cbea90 lint: replace assertion in initialization with proper error message 2021-03-19 01:02:52 +00:00
rillig
674baf6361 lint: rename push_member and pop_member
These two functions are supposed to model the designator that is used
for initializing structs and arrays.  The implementation is still buggy
and does not work at all for C99 designators with multiple names, see
d_init_pop_member.c.

For now, just rename the functions to head in the right direction.

No functional change.
2021-03-19 00:55:02 +00:00
rillig
bde88c228c lint: extend documentation about initialization
No functional change.
2021-03-19 00:39:17 +00:00
rillig
89239b6de5 lint: split initstack_pop_item into separate functions
No functional change.
2021-03-19 00:19:32 +00:00
rillig
e2bce8130d lint: improve debug logging in initstack_push
No functional change outside debug mode.
2021-03-19 00:08:13 +00:00
rillig
dc7202e285 lint: split initstack_push into smaller functions
No functional change.
2021-03-18 23:45:20 +00:00
rillig
d68805fd28 lint: clean up control flow in initstack_push
No functional change.
2021-03-18 23:37:31 +00:00
rillig
77fa05a23f lint: extract extend_if_array_of_unknown_size from initstack_push
No functional change.
2021-03-18 23:23:40 +00:00
rillig
d30c5846db lint: replace undefined behavior during initialization with assertion
This only affects code that is already rejected by the compiler.
2021-03-18 22:51:32 +00:00
rillig
b4cc35448b lint: improve debug logging during initialization
No functional change outside debug mode.
2021-03-18 22:08:05 +00:00
rillig
5f25f85e8f lint: make the debug log for nodes more readable
The operator NAME has the name 'name', therefore no special case is
needed.

Having the words 'with type' in the message makes the message easier to
find from the debug log.  Given that the operator name is used unquoted,
the log message 'name: int value=111' was nearly impossible to find in
the code.

Replace the '()' with an actual word, to avoid any confusion about
whether the type name might be a function type without prototype.

Reduce the amount of '=' signs, instead use commas to separate the
properties of the node.

No functional change outside debug mode.
2021-03-18 22:05:33 +00:00
rillig
b1117d0cb9 lint: rename operator 'const' to 'constant'
The previous name could be too easily confused with the type qualifier
'const'.  The operator name is mainly used in the debug log, only
occasionally in the output.  Since 'constant' is not a "real" operator,
it probably doesn't occur in messages at all.
2021-03-18 21:56:34 +00:00
rillig
ebe3bde9bf lint: reword message about type mismatch in initialization
Using parentheses for quotes is unusual, furthermore the previous
message didn't follow proper grammar rules, sacrificing clarity for
brevity.
2021-03-18 21:26:56 +00:00
rillig
e82f0a6950 lint: reduce debug logging for initialization, update documentation
No functional change outside debug mode.
2021-03-18 20:55:58 +00:00
rillig
ce64b8cc18 lint: document how initialization works, improve debug logging
No functional change outside debug mode.
2021-03-18 20:22:50 +00:00
rillig
1250e70dfe lint: document the initialization of an object in more detail
This will help fixing the bugs that are currently demonstrated in
msg_168.c and d_struct_init_nested.c.
2021-03-18 14:58:44 +00:00
rillig
d8304c1dc3 lint: add debug logging for C99-style initialization of arrays
No functional change outside debug mode.
2021-03-17 15:45:30 +00:00
rillig
59329564e5 lint: move debug logging for the designator to the top of the code
The debugging code is needed by the soon-to-be-added proper handling of
array subscript initializers such as '.member[123].member = 12345'.

No functional change.
2021-03-17 15:37:42 +00:00
rillig
d07ef6733f lint: clean up documentation of dinfo_t
No functional change.
2021-03-17 02:24:06 +00:00
rillig
c026af7a30 lint: rename dinfo_t members to be more expressive
While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.
2021-03-17 02:18:03 +00:00