Module Name: src Committed By: rillig Date: Sun Jan 16 10:11:38 UTC 2022
Modified Files: src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp Log Message: tests/lint: document why accidental double semicolons are hard to detect To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/xlint/lint1/msg_193.c cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/xlint/lint1/msg_193.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_193.c diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.16 src/tests/usr.bin/xlint/lint1/msg_193.c:1.17 --- src/tests/usr.bin/xlint/lint1/msg_193.c:1.16 Sat Jan 15 23:21:34 2022 +++ src/tests/usr.bin/xlint/lint1/msg_193.c Sun Jan 16 10:11:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_193.c,v 1.16 2022/01/15 23:21:34 rillig Exp $ */ +/* $NetBSD: msg_193.c,v 1.17 2022/01/16 10:11:38 rillig Exp $ */ # 3 "msg_193.c" // Test for message: statement not reached [193] @@ -672,6 +672,27 @@ test_null_statement(void) ;; /* + * If assertions are disabled with -DNDEBUG and __lint__ is defined, + * NetBSD's <assert.h> defines assert(x) to nothing, leaving only + * the trailing semicolon. If there are several assertions next to + * each other, without any whitespace in between (very unusual), the + * GCC preprocessor generates ";;" for them, which makes them + * indistinguishable from the literal ";;" from the typo above. + * + * (echo '#include <assert.h>'; echo 'assert(0);assert(1);') \ + * | gcc -DNDEBUG -E - -D__lint__ + * + * To actually see the difference, lint would need to look at the + * code before preprocessing and compare it with the preprocessed + * code, which would be a lot of work. + * + * Apart from the above edge case, detecting extra semicolons would + * be possible, but lint would have to look at the whitespace between + * the tokens, and this is something that it doesn't do at all, as of + * 2022-01-16. + */ + + /* * A stand-alone null statement, on the other hand, has its purpose. * Without it, the 'for' loop would not be complete. The NetBSD * style is to use 'continue;' instead of a simple ';'. Index: src/tests/usr.bin/xlint/lint1/msg_193.exp diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.15 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.16 --- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.15 Sat Jan 15 23:21:34 2022 +++ src/tests/usr.bin/xlint/lint1/msg_193.exp Sun Jan 16 10:11:38 2022 @@ -87,4 +87,4 @@ msg_193.c(597): warning: statement not r msg_193.c(606): warning: statement not reached [193] msg_193.c(627): warning: statement not reached [193] msg_193.c(655): warning: statement not reached [193] -msg_193.c(683): warning: statement not reached [193] +msg_193.c(704): warning: statement not reached [193]