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 lint: add tests that trigger a few...
details: https://anonhg.NetBSD.org/src/rev/94749bbb8c15
branches: trunk
changeset: 959046:94749bbb8c15
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jan 30 17:02:58 2021 +0000
description:
lint: add tests that trigger a few more messages
diffstat:
tests/usr.bin/xlint/lint1/msg_216.c | 12 +++++++++---
tests/usr.bin/xlint/lint1/msg_216.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_217.c | 10 +++++++---
tests/usr.bin/xlint/lint1/msg_217.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_220.c | 24 +++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_220.exp | 3 ++-
tests/usr.bin/xlint/lint1/msg_223.c | 10 +++++++---
tests/usr.bin/xlint/lint1/msg_223.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_224.c | 10 +++++++---
tests/usr.bin/xlint/lint1/msg_224.exp | 7 ++++++-
10 files changed, 62 insertions(+), 20 deletions(-)
diffs (142 lines):
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_216.c
--- a/tests/usr.bin/xlint/lint1/msg_216.c Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_216.c Sat Jan 30 17:02:58 2021 +0000
@@ -1,7 +1,13 @@
-/* $NetBSD: msg_216.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
+/* $NetBSD: msg_216.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
# 3 "msg_216.c"
// Test for message: function %s has return (e); and return; [216]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* implicit int */
+random(int n)
+{
+ if (n < 0)
+ return -3;
+ if (n < 2)
+ return;
+} /* expect: 216 */
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_216.exp
--- a/tests/usr.bin/xlint/lint1/msg_216.exp Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_216.exp Sat Jan 30 17:02:58 2021 +0000
@@ -1,1 +1,1 @@
-msg_216.c(6): syntax error ':' [249]
+msg_216.c(13): warning: function random has return (e); and return; [216]
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_217.c
--- a/tests/usr.bin/xlint/lint1/msg_217.c Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_217.c Sat Jan 30 17:02:58 2021 +0000
@@ -1,7 +1,11 @@
-/* $NetBSD: msg_217.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
+/* $NetBSD: msg_217.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
# 3 "msg_217.c"
// Test for message: function %s falls off bottom without returning value [217]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+int
+random(int n)
+{
+ if (n < 0)
+ return -3;
+} /* expect: 217 */
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_217.exp
--- a/tests/usr.bin/xlint/lint1/msg_217.exp Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_217.exp Sat Jan 30 17:02:58 2021 +0000
@@ -1,1 +1,1 @@
-msg_217.c(6): syntax error ':' [249]
+msg_217.c(11): warning: function random falls off bottom without returning value [217]
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_220.c
--- a/tests/usr.bin/xlint/lint1/msg_220.c Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_220.c Sat Jan 30 17:02:58 2021 +0000
@@ -1,7 +1,25 @@
-/* $NetBSD: msg_220.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
+/* $NetBSD: msg_220.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
# 3 "msg_220.c"
// Test for message: fallthrough on case statement [220]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -h */
+
+extern void
+println(const char *);
+
+void
+example(int n)
+{
+ switch (n) {
+ case 1:
+ case 3:
+ case 5:
+ println("odd");
+ case 2: /* expect: 220 */
+ case 7:
+ println("prime");
+ default: /* expect: 284 */
+ println("number");
+ }
+}
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_220.exp
--- a/tests/usr.bin/xlint/lint1/msg_220.exp Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_220.exp Sat Jan 30 17:02:58 2021 +0000
@@ -1,1 +1,2 @@
-msg_220.c(6): syntax error ':' [249]
+msg_220.c(19): warning: fallthrough on case statement [220]
+msg_220.c(22): warning: fallthrough on default statement [284]
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_223.c
--- a/tests/usr.bin/xlint/lint1/msg_223.c Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_223.c Sat Jan 30 17:02:58 2021 +0000
@@ -1,7 +1,11 @@
-/* $NetBSD: msg_223.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
+/* $NetBSD: msg_223.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
# 3 "msg_223.c"
// Test for message: end-of-loop code not reached [223]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example(int n)
+{
+ for (int i = 0; i < n; i++) /* expect: 223 */
+ break;
+}
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_223.exp
--- a/tests/usr.bin/xlint/lint1/msg_223.exp Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_223.exp Sat Jan 30 17:02:58 2021 +0000
@@ -1,1 +1,1 @@
-msg_223.c(6): syntax error ':' [249]
+msg_223.c(9): warning: end-of-loop code not reached [223]
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_224.c
--- a/tests/usr.bin/xlint/lint1/msg_224.c Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_224.c Sat Jan 30 17:02:58 2021 +0000
@@ -1,7 +1,11 @@
-/* $NetBSD: msg_224.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
+/* $NetBSD: msg_224.c,v 1.2 2021/01/30 17:02:58 rillig Exp $ */
# 3 "msg_224.c"
// Test for message: cannot recover from previous errors [224]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void example1(void) { "syntax" error; } /* expect: 249 */
+void example2(void) { "syntax" error; } /* expect: 249 */
+void example3(void) { "syntax" error; } /* expect: 249 */
+void example4(void) { "syntax" error; } /* expect: 249 */
+void example5(void) { "syntax" error; } /* expect: 249, 224 */
+void example6(void) { "syntax" error; }
diff -r 902b419b4d7b -r 94749bbb8c15 tests/usr.bin/xlint/lint1/msg_224.exp
--- a/tests/usr.bin/xlint/lint1/msg_224.exp Sat Jan 30 16:05:45 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_224.exp Sat Jan 30 17:02:58 2021 +0000
@@ -1,1 +1,6 @@
-msg_224.c(6): syntax error ':' [249]
+msg_224.c(6): syntax error 'error' [249]
+msg_224.c(7): syntax error 'error' [249]
+msg_224.c(8): syntax error 'error' [249]
+msg_224.c(9): syntax error 'error' [249]
+msg_224.c(10): syntax error 'error' [249]
+msg_224.c(10): cannot recover from previous errors [224]
Home |
Main Index |
Thread Index |
Old Index