Received: by mail.netbsd.org (Postfix, from userid 605) id E6E3B84D51; Thu, 8 Jul 2021 18:50:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 25DF084D55 for ; Thu, 8 Jul 2021 18:50:58 +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 7nsZjX87SJVI for ; Thu, 8 Jul 2021 18:50:57 +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 AA9D984D24 for ; Thu, 8 Jul 2021 18:50:57 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 9D11CFA95; Thu, 8 Jul 2021 18:50:57 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Thu, 8 Jul 2021 18:50:57 +0000 From: "Roland Illig" Subject: CVS commit: src To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20210708185057.9D11CFA95@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: Thu Jul 8 18:50:57 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp src/usr.bin/xlint/lint1: cgram.y Log Message: lint: demonstrate bug in handling enum declarations (since today) Since cgram.y 1.270 from today (a "cleanup" commit), the enum constants were only registered in the symbol table, but they were not added to the enum type (en_first_enumerator). That information is used for validating switch statements on enum types. The actual bug is an off-by-one error in the grammar, in the grammar rule 'enum_declaration'. Yacc does not notice this obvious error. Bison does, but it is not involved in building lint. In the grammar rule 'enum_declaration', the intended $3 contains the first enumeration constant of the type, while $2, which yacc interprets as a symbol, contains a null pointer, at least on x86_64. The existing tests did not cover this scenario, so the bug went unnoticed. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_206.c \ src/tests/usr.bin/xlint/lint1/msg_206.exp cvs rdiff -u -r1.271 -r1.272 src/usr.bin/xlint/lint1/cgram.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.