Received: by mail.netbsd.org (Postfix, from userid 605) id 1736184D17; Tue, 30 Mar 2021 14:25:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 4BA0884D12 for ; Tue, 30 Mar 2021 14:25:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id xT2u5QjFOW6x for ; Tue, 30 Mar 2021 14:25:28 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id B1C5584CDF for ; Tue, 30 Mar 2021 14:25:28 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id A4898FA95; Tue, 30 Mar 2021 14:25:28 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Tue, 30 Mar 2021 14:25:28 +0000 From: "Roland Illig" Subject: CVS commit: src To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20210330142528.A4898FA95@cvs.NetBSD.org> Sender: source-changes-owner@NetBSD.org List-Id: Precedence: bulk Reply-To: source-changes-d@NetBSD.org Mail-Reply-To: "Roland Illig" Mail-Followup-To: source-changes-d@NetBSD.org List-Unsubscribe: Module Name: src Committed By: rillig Date: Tue Mar 30 14:25:28 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool.c d_c99_init.c d_c99_init.exp d_init_array_using_string.c d_init_array_using_string.exp d_init_pop_member.c d_init_pop_member.exp src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h init.c Log Message: lint: rewrite handling of initializations, fixing several bugs The previous implementation had a wrong model of how initialization happens in C99, its assertions failed in all kind of edge cases and it was not possible to fix the remaining bugs one at a time without running into even more obscure assertion failures. The debug logging was detailed but did not help to clarify the situation. After about 20 failed attempts at fixing the small details I decided to start all over and rewrite the initialization code from scratch. I left the low-level parts of handling designators, the code that is independent of brace_level and the high-level parts of how the parser calls into this module. Everything else is completely new. The concept of a brace level stays since that is how C99 describes initialization. The previous code could not handle multi-level designations (see d_init_pop_member.c). There are no more assertion failures in the initialization code. Some TODO comments have been left in the tests to keep the line numbers the same in this commit. These will be cleaned up in a follow-up commit. The new implementation does not handle initialization with "missing" braces. This is an edge case that both GCC and Clang warn about, so it is not widely used. If necessary, it may be added later. The new implementation does not use any global variables in the vast majority of the functions, to make all dependencies and possible modifications obvious. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/d_c99_bool.c \ src/tests/usr.bin/xlint/lint1/d_init_pop_member.c cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/xlint/lint1/d_c99_init.c cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/xlint/lint1/d_c99_init.exp cvs rdiff -u -r1.2 -r1.3 \ src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c \ src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/d_init_pop_member.exp cvs rdiff -u -r1.206 -r1.207 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.166 -r1.167 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.94 -r1.95 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.178 -r1.179 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.