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 a few more tests
details: https://anonhg.NetBSD.org/src/rev/dfbf55cc040f
branches: trunk
changeset: 959082:dfbf55cc040f
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jan 31 09:21:24 2021 +0000
description:
lint: add a few more tests
diffstat:
tests/usr.bin/xlint/lint1/msg_003.c | 12 +++++++++---
tests/usr.bin/xlint/lint1/msg_003.exp | 4 +++-
tests/usr.bin/xlint/lint1/msg_085.c | 8 +++++---
tests/usr.bin/xlint/lint1/msg_085.exp | 6 ++++--
tests/usr.bin/xlint/lint1/msg_243.c | 24 +++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_243.exp | 5 ++++-
6 files changed, 46 insertions(+), 13 deletions(-)
diffs (97 lines):
diff -r 4fc7b3227fbc -r dfbf55cc040f tests/usr.bin/xlint/lint1/msg_003.c
--- a/tests/usr.bin/xlint/lint1/msg_003.c Sun Jan 31 08:59:40 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_003.c Sun Jan 31 09:21:24 2021 +0000
@@ -1,7 +1,13 @@
-/* $NetBSD: msg_003.c,v 1.1 2021/01/02 10:22:42 rillig Exp $ */
+/* $NetBSD: msg_003.c,v 1.2 2021/01/31 09:21:24 rillig Exp $ */
# 3 "msg_003.c"
// Test for message: %s declared in argument declaration list [3]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/*ARGSUSED*/
+void
+example(declare_struct, declare_union, declare_enum)
+ struct struct_in_argument *declare_struct;
+ union union_in_argument *declare_union;
+ enum enum_in_argument *declare_enum;
+{
+}
diff -r 4fc7b3227fbc -r dfbf55cc040f tests/usr.bin/xlint/lint1/msg_003.exp
--- a/tests/usr.bin/xlint/lint1/msg_003.exp Sun Jan 31 08:59:40 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_003.exp Sun Jan 31 09:21:24 2021 +0000
@@ -1,1 +1,3 @@
-msg_003.c(6): syntax error ':' [249]
+msg_003.c(9): warning: struct declared in argument declaration list [3]
+msg_003.c(10): warning: union declared in argument declaration list [3]
+msg_003.c(11): warning: enum declared in argument declaration list [3]
diff -r 4fc7b3227fbc -r dfbf55cc040f tests/usr.bin/xlint/lint1/msg_085.c
--- a/tests/usr.bin/xlint/lint1/msg_085.c Sun Jan 31 08:59:40 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_085.c Sun Jan 31 09:21:24 2021 +0000
@@ -1,9 +1,11 @@
-/* $NetBSD: msg_085.c,v 1.2 2021/01/02 18:06:01 rillig Exp $ */
+/* $NetBSD: msg_085.c,v 1.3 2021/01/31 09:21:24 rillig Exp $ */
# 3 "msg_085.c"
// Test for message: dubious tag declaration: %s %s [85]
-extern int stat(struct stat *);
+void declare_struct(struct in_argument *); /* expect: 85 */
+void declare_union(union in_argument *); /* expect: 85 */
+void declare_enum(enum in_argument *); /* expect: 85 */
-struct ok;
+struct ok; /* expect: 233 */
extern int ok(struct ok *);
diff -r 4fc7b3227fbc -r dfbf55cc040f tests/usr.bin/xlint/lint1/msg_085.exp
--- a/tests/usr.bin/xlint/lint1/msg_085.exp Sun Jan 31 08:59:40 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_085.exp Sun Jan 31 09:21:24 2021 +0000
@@ -1,2 +1,4 @@
-msg_085.c(6): warning: dubious tag declaration: struct stat [85]
-msg_085.c(8): warning: struct ok never defined [233]
+msg_085.c(6): warning: dubious tag declaration: struct in_argument [85]
+msg_085.c(7): warning: dubious tag declaration: union in_argument [85]
+msg_085.c(8): warning: dubious tag declaration: enum in_argument [85]
+msg_085.c(10): warning: struct ok never defined [233]
diff -r 4fc7b3227fbc -r dfbf55cc040f tests/usr.bin/xlint/lint1/msg_243.c
--- a/tests/usr.bin/xlint/lint1/msg_243.c Sun Jan 31 08:59:40 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_243.c Sun Jan 31 09:21:24 2021 +0000
@@ -1,7 +1,25 @@
-/* $NetBSD: msg_243.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */
+/* $NetBSD: msg_243.c,v 1.2 2021/01/31 09:21:24 rillig Exp $ */
# 3 "msg_243.c"
// Test for message: dubious comparison of enums, op %s [243]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -eP */
+
+enum color {
+ RED, GREEN, BLUE
+};
+
+void eval(_Bool);
+
+/* TODO: There should be a way to declare an enum type as "ordered ok". */
+
+void
+example(enum color a, enum color b)
+{
+ eval(a < b); /* expect: 243 */
+ eval(a <= b); /* expect: 243 */
+ eval(a > b); /* expect: 243 */
+ eval(a >= b); /* expect: 243 */
+ eval(a == b);
+ eval(a != b);
+}
diff -r 4fc7b3227fbc -r dfbf55cc040f tests/usr.bin/xlint/lint1/msg_243.exp
--- a/tests/usr.bin/xlint/lint1/msg_243.exp Sun Jan 31 08:59:40 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_243.exp Sun Jan 31 09:21:24 2021 +0000
@@ -1,1 +1,4 @@
-msg_243.c(6): syntax error ':' [249]
+msg_243.c(19): warning: dubious comparison of enums, op < [243]
+msg_243.c(20): warning: dubious comparison of enums, op <= [243]
+msg_243.c(21): warning: dubious comparison of enums, op > [243]
+msg_243.c(22): warning: dubious comparison of enums, op >= [243]
Home |
Main Index |
Thread Index |
Old Index