From the previous short names, it was no obvious that these functions
create a new tree node.
The function named funccall in lint2 has been left as-is, since it has a
completely different prototype.
Most of the code that deals with control statements is only interested
in the innermost control statement, and not if that is a stack or not.
Therefore, emphasize that part in the variable name.
The member c_next was confusing since the "direction" of this "next
element" was ambiguous. In a sequence of if statements, the "next"
element could have equally been the following one, not the surrounding
one.
It's shorter, and the other flags of the type or declaration also don't
have "is" in their names. Except for t_isenum, but that's because there
is a macro named t_enum that would interfere with that name.
Since several years GCC validates printf-style strings, and there is no
reason not to let GCC do that work. This prevents bugs like the
segmentation fault that was fixed in tree.c 1.109 from 2021-01-01.
By default, lint is compiled with DEBUG off, but it's easy enough to
compile it in debug mode once in a while.
The return value was only used in a single case. Duplicating the
condition for printing a message is ok in that case, since it makes all
other places in the code simpler.
The occasional "(void)" or "msg = " before the function call had hidden
the calls from check-msgs.lua, which didn't check the message texts in
such cases.
Even though this results in more lines of code, the benefit is that the
message text in the comment is verified by check-msgs.lua. The code is
also easier to read, the parentheses and asterisk were not needed.
Previously, most type names had been cut off after 63 significant
characters. In some cases, 127 characters survived, or 255. And for
the debugging messages, sometimes even 1023. This inconsistency was
useless.
It was wrong in the first place to make the caller of the function
tyname responsible for handling the buffer. That's not something a
caller of such a simple function should do. These callers have better
things to do.
The API of the new function type_name is as simple as possible.
In the implementation, the name of the type is generated anew each time.
I just didn't know whether the type details could change, once the type
is initialized, and I didn't want to find out. To be on the safe side,
the resulting type name is cached, independently of the type it was
generated for. Using a trivial, unbalanced binary tree should be good
enough for now.
All this work is necessary to support adding new debug logging, without
being distracted by irrelevant implementation details such as these
buffer sizes. Adding new debug messages should be fun and easy; up to
now, it was overly bureaucratic.
The variable namemem is supposed to be a circular list, which is
"documented" implicitly in push_member.
The implementation was buggy though. In pop_member, the circular list
was destroyed though. Given the list (capital, major, favorite_color,
green), removing capital made major point to itself in the forward
direction, even though it should not have been modified at all.
In the test, I had been too optimistic to quickly understand the code
around variable initialization. I was wrong though, so I had to adjust
the comments there to reality.
These flags are missing the options -g (GNUisms) and -S (C9X mode).
Without these flags, NetBSD's system headers cannot be compiled as they
make heavy use of __inline and __attribute__.
This works around GCC 9, which didn't see that the following statement
cannot terminate normally, even though 0 is obviously a constant expression
and assert_failed is marked as __attribute__((__noreturn__)).
do {
if (!(0))
assert_failed(...);
} while (0)
The only thing these cases have in common is the name "label" and the
"reached = 1" assignment. That's not reason enough to combine
completely unrelated functions.
Splitting the code arbitrarily in separate phases made the code harder
to understand, both for humans as well as automated tools.
One of these tools, check-msgs.lua, couldn't check whether the comments
match the actual messages, and of course, the comments were wrong.
There was no good reason to deviate from the pattern followed by all the
rest of the code.
This removes the redundancy of mentioning the function name in the error
message. This redundancy had been correct in all but 2 cases:
build_real_imag and tsize.