Module Name: src Committed By: rillig Date: Tue Mar 23 18:40:50 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_171.c msg_171.exp src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h init.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_171.c \ src/tests/usr.bin/xlint/lint1/msg_171.exp cvs rdiff -u -r1.197 -r1.198 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.158 -r1.159 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.83 -r1.84 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.110 -r1.111 src/usr.bin/xlint/lint1/init.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.