Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: add examples for bogus...
details: https://anonhg.NetBSD.org/src/rev/a566abcd2cd1
branches: trunk
changeset: 989016:a566abcd2cd1
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Oct 09 21:25:39 2021 +0000
description:
tests/lint: add examples for bogus warning 160 and for error 323
diffstat:
tests/usr.bin/xlint/lint1/msg_160.c | 14 +++++++++++++-
tests/usr.bin/xlint/lint1/msg_160.exp | 1 +
tests/usr.bin/xlint/lint1/msg_323.c | 20 +++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_323.exp | 2 +-
4 files changed, 32 insertions(+), 5 deletions(-)
diffs (66 lines):
diff -r 0e3d11c54d03 -r a566abcd2cd1 tests/usr.bin/xlint/lint1/msg_160.c
--- a/tests/usr.bin/xlint/lint1/msg_160.c Sat Oct 09 21:06:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_160.c Sat Oct 09 21:25:39 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_160.c,v 1.5 2021/01/31 12:20:00 rillig Exp $ */
+/* $NetBSD: msg_160.c,v 1.6 2021/10/09 21:25:39 rillig Exp $ */
# 3 "msg_160.c"
// Test for message: operator '==' found where '=' was expected [160]
@@ -56,3 +56,15 @@
*/
eval(a == (b == c));
}
+
+/* Seen in bin/csh/dir.c 1.35 from 2020-08-09, line 223. */
+void
+assignment_in_comma_expression(void)
+{
+ int len;
+
+ /* FIXME: The following code is totally fine. */
+ /* expect+1: warning: operator '==' found where '=' was expected [160] */
+ if ((len = 3, len == 0))
+ return;
+}
diff -r 0e3d11c54d03 -r a566abcd2cd1 tests/usr.bin/xlint/lint1/msg_160.exp
--- a/tests/usr.bin/xlint/lint1/msg_160.exp Sat Oct 09 21:06:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_160.exp Sat Oct 09 21:25:39 2021 +0000
@@ -1,2 +1,3 @@
msg_160.c(30): warning: operator '==' found where '=' was expected [160]
msg_160.c(43): warning: operator '==' found where '=' was expected [160]
+msg_160.c(68): warning: operator '==' found where '=' was expected [160]
diff -r 0e3d11c54d03 -r a566abcd2cd1 tests/usr.bin/xlint/lint1/msg_323.c
--- a/tests/usr.bin/xlint/lint1/msg_323.c Sat Oct 09 21:06:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_323.c Sat Oct 09 21:25:39 2021 +0000
@@ -1,7 +1,21 @@
-/* $NetBSD: msg_323.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_323.c,v 1.3 2021/10/09 21:25:39 rillig Exp $ */
# 3 "msg_323.c"
// Test for message: continue in 'do ... while (0)' loop [323]
+void println(const char *);
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void
+example(const char *p)
+{
+ do {
+ switch (*p) {
+ case 'a':
+ continue; /* leaves the 'do while 0' */
+ case 'b':
+ break; /* leaves the 'switch' */
+ }
+ println("b");
+ /* XXX: Is that really worth an error? */
+ /* expect+1: error: continue in 'do ... while (0)' loop [323] */
+ } while (0);
+}
diff -r 0e3d11c54d03 -r a566abcd2cd1 tests/usr.bin/xlint/lint1/msg_323.exp
--- a/tests/usr.bin/xlint/lint1/msg_323.exp Sat Oct 09 21:06:31 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_323.exp Sat Oct 09 21:25:39 2021 +0000
@@ -1,1 +1,1 @@
-msg_323.c(6): error: syntax error ':' [249]
+msg_323.c(20): error: continue in 'do ... while (0)' loop [323]
Home |
Main Index |
Thread Index |
Old Index