Commit Graph

17540 Commits

Author SHA1 Message Date
rillig
1c9e647c42 lint: rename the few remaining instances of 'namedmem'
No functional change.
2021-03-25 19:33:44 +00:00
rillig
a58d119dde lint: split current_namedmem into lvalue and rvalue form, rename them
This is a small step towards using the terminology from C99.

No functional change.
2021-03-25 19:20:15 +00:00
rillig
0cb32f4608 lint: inline macro 'namedmem' for C99 designators
No functional change.
2021-03-25 19:11:18 +00:00
rillig
e44d626769 lint: free memory at the end of an initialization
No functional change, just more clarity in the code.
2021-03-25 16:43:51 +00:00
rillig
7d8ec13de2 lint: condense debug output for initializations
This way it does not look more impressive than it really is.

No functional change outside debug mode.
2021-03-25 16:30:23 +00:00
rillig
6d41f06e4c lint: add comments about things left to do, from code review
No functional change.
2021-03-25 13:10:19 +00:00
nia
e11a27e948 Add an example for recording CD quality audio 2021-03-25 10:03:26 +00:00
rillig
aadb627a71 lint: fix C99 initialization with expression of type 'struct'
This has been a long-standing limitation of lint.  Now it is almost
ready for C99, see the list of "major changes" in the foreword of C99.

One known remaining bug in the area of initialization is designators
with several levels, such as '.member[2].member.member'.  Oh, and
designators for arrays are only supported in the parser but not in the
type checker.  There's still some work to do.
2021-03-25 01:42:53 +00:00
rillig
586d0a84e9 lint: remove outdated comment from init_using_expr
Since C99, an aggregate type can be initialized without braces.

No functional change.
2021-03-25 00:48:58 +00:00
rillig
9d0a894bfa lint: extract check_init_expr from init_using_expr
No functional change.
2021-03-25 00:35:16 +00:00
rillig
e92d4ad150 lint: fix wrong warning about initialization using string literal
Missing braces after 'if', since init.c 1.68 from 2021-02-20.

GCC 10 doesn't complain about this even with -Wmisleading-indentation
since at least one of the involved lines is a macro invocation (in this
case both lines).  GCC 11 will warn about this.

Clang warns about this, but the regular Clang build currently fails for
other reasons, so this problem didn't show up there either.
2021-03-23 22:58:08 +00:00
christos
cf91e4bb2b Add _Alignas() 2021-03-23 20:57:40 +00:00
rillig
c40f4a5057 lint: extract init_using_assign from init_using_expr
No functional change.
2021-03-23 20:21:07 +00:00
rillig
7c67467864 lint: merge duplicate code in init_using_expr
No functional change.
2021-03-23 20:14:55 +00:00
rillig
49b3d03d05 lint: fix documentation about optional braces in initializers 2021-03-23 18:51:43 +00:00
rillig
131c7001fe lint: fix wrong error message about type mismatch in compound literal
Now that the code contains explicit markers for starting and ending an
initialization, and having the guarantee that an assertion fails
whenever some code accesses the state of the "current initialization"
even though there is no ongoing initialization gives me much more
confidence in the correctness of the code.  The calls to
begin_initialization and end_initialization always appear in pairs,
enclosing the minimal amount of code necessary for initialization.

In a nutshell, global modifiable state is error-prone and hard to
understand.

A nice side effect is that the grammar no longer needs a special rule
for the outermost initializer since the functions for the debug logging
are now called explicitly.

The code that misuses the initialization state just because it needs to
temporarily store a sym_t somewhere is now clearly marked as such.  A
GCC statement expression can appear anywhere and is therefore
independent of the initialization.  Most probably the code can simply
refer to the local variable in the grammar rule itself, or this variable
needs to be encoded in the grammar %union.  For sure there is a better
way to handle this.

There is no longer a need that the function 'declare' initializes the
initialization state, it was just the wrong place to do this.
2021-03-23 18:40:50 +00:00
rillig
19b0e62cf4 lint: add indirection for accessing the current initialization
This indirection will be needed to handle nested initializations, which
are a new feature of C99.  These are currently not handled correctly,
see msg_171.c.

No functional change.
2021-03-23 17:36:55 +00:00
rillig
a2e7847c63 lint: reduce visibility of variables for initializations
No functional change.
2021-03-22 19:29:43 +00:00
rillig
cb3c7a45cf lint: reduce visibility of global variable for getopt check
No functional change.
2021-03-22 19:25:08 +00:00
rillig
771299944e lint: use precise type information in message about type mismatch
While here, reword the message, avoiding operators and parentheses.

Since 2021-01-02, providing the precise type name is as easy as the
broad type classification (just replace tspec_name with type_name), and
it's definitely more useful to the human readers.
2021-03-22 15:29:43 +00:00
rillig
490538eb4d make: fix typos in documentation of ModChain 2021-03-21 23:03:33 +00:00
rillig
ab16413a62 lint: prefix error messages with 'error:'
This makes it easier to find these errors in the build logs.
2021-03-21 20:44:59 +00:00
rillig
494aa35c5b lint: remove redundant prototypes
No functional change.
2021-03-21 20:30:19 +00:00
rillig
f838b057fa lint: adjust type in documentation of add_array
No functional change.
2021-03-21 20:18:45 +00:00
rillig
ac846d67c2 lint: warn about unreachable statement after joining the 'if' branches 2021-03-21 19:14:40 +00:00
rillig
f32d16fd5a lint: invert 'rchflag', call it warn_about_unreachable instead
No functional change.
2021-03-21 19:08:10 +00:00
rillig
5db61676e0 lint: reduce number of places where 'reached' is set
When determining the reachability of a statement, the idea was that
whenever 'reached' was set to false, 'rchflg' (the abbreviation for "do
not warn about unreachable statements") would be reset as well.

In some (trivial) cases, this was done, but many more interesting cases
simply forgot to set this second variable.  To prevent this in the
future, encapsulate this in a simple helper function.

Now even if a statement is reachable, 'rchflg' gets reset.  This does
not hurt since as long as the current statement is reachable, the value
of 'rchflg' does not matter.

No functional change.  There would be quite a big functional change
though if check_statement_reachable were to reset 'rchflg' instead of
'reached', as the comment already suggests.  In that case, with the
current code, many legitimate warnings about unreachable statements
would be skipped, especially those involving 'if' statements, since
these didn't reset 'rchflg' properly before.
2021-03-21 18:58:34 +00:00
rillig
792d6541e8 lint: fix reachability for while (0) 2021-03-21 15:44:57 +00:00
rillig
62b887ae9d lint: fix reachability for constant controlling expression in for loop 2021-03-21 15:34:13 +00:00
rillig
352b5b3b4b lint: fix reachability for if-then-else statements 2021-03-21 15:24:55 +00:00
rillig
f23731fc8b lint: rename functions for handling control statements
No functional change.
2021-03-21 14:49:21 +00:00
rillig
97e5c72af7 lint: fix reachability computation in if statements
Previously, only loop statements were considered for reachability.  This
ignored the possibility of an early return in an if statement, or
unreachable branches.
2021-03-21 14:36:59 +00:00
rillig
65ab73b7c4 lint: add missing space when adding a new test case 2021-03-21 13:10:58 +00:00
rillig
4e6f02877c lint: rename c_rchif to c_reached_end_of_then
No functional change.
2021-03-21 13:03:42 +00:00
rillig
d19f53645a lint: document why an unreachable statement is set to reachable
No functional change.
2021-03-21 12:10:27 +00:00
rillig
2703dc53ce lint: rename c_cont to c_continue
No functional change.
2021-03-21 12:08:34 +00:00
rillig
20bc44c056 lint: document the precise meaning of control_statement.c_break
No functional change.
2021-03-21 12:06:10 +00:00
rillig
6c32983dfe lint: rename i_infinite to i_maybe_endless
Not every loop that has 'while (1)' is an endless loop.  It may still
contain a 'return' somewhere.
2021-03-21 12:03:56 +00:00
rillig
8c4298c341 lint: fix wrong 'falls off bottom' after return in do-while 2021-03-21 11:55:59 +00:00
rillig
85a09d20fa lint: fix wrong 'statement not reached' in do-while loop 2021-03-21 11:48:04 +00:00
rillig
299565f1d9 lint: remove redundant braces in doreturn
No functional change.
2021-03-21 11:38:24 +00:00
nia
bc9df35069 audioctl.1: describe foibles 2021-03-21 10:50:08 +00:00
rillig
07746a75ad lint: rename d_fargs, d_fdpos and d_fpsyms to be less abbreviated
No functional change.
2021-03-21 10:30:28 +00:00
rillig
4baf940241 lint: rename d_nedecl to d_nonempty_decl
No functional change.
2021-03-21 10:25:40 +00:00
rillig
b7e78ec23d lint: rename d_rdcsym to d_redeclared_symbol
No functional change.
2021-03-21 10:21:07 +00:00
rillig
94e7a0615e lint: inline local variable in declarator_1_struct_union
No functional change.
2021-03-21 10:16:12 +00:00
rillig
c509e4baa5 lint: rename clst to case_labels
No functional change.
2021-03-21 10:08:01 +00:00
rillig
7dc34efc1f lint: rename declspecs to declaration_specifiers, just as in C99
No functional change.
2021-03-21 09:54:02 +00:00
rillig
7e6909cce4 lint: rename grammar rule 'data_def' to 'top_level_declaration'
No functional change.
2021-03-21 09:49:34 +00:00
rillig
6474e49f87 lint: remove redundant '%prec' declarations from the grammar
No change to the generated binary.
2021-03-21 09:22:35 +00:00