Module Name: src Committed By: rillig Date: Sat Oct 9 22:03:38 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_230.c msg_230.exp Log Message: tests/lint: demonstrate wrong warning about nonportable char comparison Seen in bin/sh/expand.c:273. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_230.c cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_230.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_230.c diff -u src/tests/usr.bin/xlint/lint1/msg_230.c:1.9 src/tests/usr.bin/xlint/lint1/msg_230.c:1.10 --- src/tests/usr.bin/xlint/lint1/msg_230.c:1.9 Sat Oct 9 21:56:12 2021 +++ src/tests/usr.bin/xlint/lint1/msg_230.c Sat Oct 9 22:03:38 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_230.c,v 1.9 2021/10/09 21:56:12 rillig Exp $ */ +/* $NetBSD: msg_230.c,v 1.10 2021/10/09 22:03:38 rillig Exp $ */ # 3 "msg_230.c" // Test for message: nonportable character comparison '%s %d' [230] @@ -112,3 +112,21 @@ compare_lt(char c) if (c >= 129) return; } + +void +compare_with_character_literal(char ch) +{ + /* + * FIXME: These comparisons are portable since the character constant + * is interpreted using the type 'char' on the exact same platform + * as where the comparison takes place. + */ + /* expect+1: warning: nonportable character comparison '== -128' [230] */ + if (ch == '\200') + return; + /* expect+1: warning: nonportable character comparison '== -1' [230] */ + if (ch == '\377') + return; + if (ch == '\000') + return; +} Index: src/tests/usr.bin/xlint/lint1/msg_230.exp diff -u src/tests/usr.bin/xlint/lint1/msg_230.exp:1.8 src/tests/usr.bin/xlint/lint1/msg_230.exp:1.9 --- src/tests/usr.bin/xlint/lint1/msg_230.exp:1.8 Sat Oct 9 21:56:12 2021 +++ src/tests/usr.bin/xlint/lint1/msg_230.exp Sat Oct 9 22:03:38 2021 @@ -16,3 +16,5 @@ msg_230.c(89): warning: nonportable char msg_230.c(105): warning: nonportable character comparison '>= 128' [230] msg_230.c(109): warning: nonportable character comparison '> 128' [230] msg_230.c(112): warning: nonportable character comparison '>= 129' [230] +msg_230.c(125): warning: nonportable character comparison '== -128' [230] +msg_230.c(128): warning: nonportable character comparison '== -1' [230]