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 for messages 117, ...
details: https://anonhg.NetBSD.org/src/rev/1fe50431f9f2
branches: trunk
changeset: 949310:1fe50431f9f2
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jan 09 14:37:16 2021 +0000
description:
lint: add tests for messages 117, 120, 125, 127
diffstat:
tests/usr.bin/xlint/lint1/msg_117.c | 35 ++++++++++++++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_117.exp | 7 ++++++-
tests/usr.bin/xlint/lint1/msg_120.c | 35 ++++++++++++++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_120.exp | 7 ++++++-
tests/usr.bin/xlint/lint1/msg_125.c | 13 ++++++++++---
tests/usr.bin/xlint/lint1/msg_125.exp | 2 +-
tests/usr.bin/xlint/lint1/msg_127.c | 14 ++++++++++----
tests/usr.bin/xlint/lint1/msg_127.exp | 10 +++++++++-
8 files changed, 106 insertions(+), 17 deletions(-)
diffs (170 lines):
diff -r 8a294b059c34 -r 1fe50431f9f2 tests/usr.bin/xlint/lint1/msg_117.c
--- a/tests/usr.bin/xlint/lint1/msg_117.c Sat Jan 09 14:33:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_117.c Sat Jan 09 14:37:16 2021 +0000
@@ -1,7 +1,36 @@
-/* $NetBSD: msg_117.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
+/* $NetBSD: msg_117.c,v 1.2 2021/01/09 14:37:16 rillig Exp $ */
# 3 "msg_117.c"
// Test for message: bitwise operation on signed value possibly nonportable [117]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -p */
+
+int
+shr(int a, int b)
+{
+ return a >> b;
+}
+
+int
+shr_lhs_constant_positive(int a)
+{
+ return 0x1234 >> a;
+}
+
+int
+shr_lhs_constant_negative(int a)
+{
+ return -0x1234 >> a;
+}
+
+int
+shr_rhs_constant_positive(int a)
+{
+ return a >> 0x1234;
+}
+
+int
+shr_rhs_constant_negative(int a)
+{
+ return a >> -0x1234;
+}
diff -r 8a294b059c34 -r 1fe50431f9f2 tests/usr.bin/xlint/lint1/msg_117.exp
--- a/tests/usr.bin/xlint/lint1/msg_117.exp Sat Jan 09 14:33:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_117.exp Sat Jan 09 14:37:16 2021 +0000
@@ -1,1 +1,6 @@
-msg_117.c(6): syntax error ':' [249]
+msg_117.c(11): warning: bitwise operation on signed value possibly nonportable [117]
+msg_117.c(23): warning: bitwise operation on signed value nonportable [120]
+msg_117.c(29): warning: bitwise operation on signed value possibly nonportable [117]
+msg_117.c(29): warning: shift greater than size of object [122]
+msg_117.c(35): warning: bitwise operation on signed value possibly nonportable [117]
+msg_117.c(35): warning: negative shift [121]
diff -r 8a294b059c34 -r 1fe50431f9f2 tests/usr.bin/xlint/lint1/msg_120.c
--- a/tests/usr.bin/xlint/lint1/msg_120.c Sat Jan 09 14:33:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_120.c Sat Jan 09 14:37:16 2021 +0000
@@ -1,7 +1,36 @@
-/* $NetBSD: msg_120.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
+/* $NetBSD: msg_120.c,v 1.2 2021/01/09 14:37:16 rillig Exp $ */
# 3 "msg_120.c"
// Test for message: bitwise operation on signed value nonportable [120]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -p */
+
+int
+shr(int a, int b)
+{
+ return a >> b;
+}
+
+int
+shr_lhs_constant_positive(int a)
+{
+ return 0x1234 >> a;
+}
+
+int
+shr_lhs_constant_negative(int a)
+{
+ return -0x1234 >> a;
+}
+
+int
+shr_rhs_constant_positive(int a)
+{
+ return a >> 0x1234;
+}
+
+int
+shr_rhs_constant_negative(int a)
+{
+ return a >> -0x1234;
+}
diff -r 8a294b059c34 -r 1fe50431f9f2 tests/usr.bin/xlint/lint1/msg_120.exp
--- a/tests/usr.bin/xlint/lint1/msg_120.exp Sat Jan 09 14:33:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_120.exp Sat Jan 09 14:37:16 2021 +0000
@@ -1,1 +1,6 @@
-msg_120.c(6): syntax error ':' [249]
+msg_120.c(11): warning: bitwise operation on signed value possibly nonportable [117]
+msg_120.c(23): warning: bitwise operation on signed value nonportable [120]
+msg_120.c(29): warning: bitwise operation on signed value possibly nonportable [117]
+msg_120.c(29): warning: shift greater than size of object [122]
+msg_120.c(35): warning: bitwise operation on signed value possibly nonportable [117]
+msg_120.c(35): warning: negative shift [121]
diff -r 8a294b059c34 -r 1fe50431f9f2 tests/usr.bin/xlint/lint1/msg_125.c
--- a/tests/usr.bin/xlint/lint1/msg_125.c Sat Jan 09 14:33:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_125.c Sat Jan 09 14:37:16 2021 +0000
@@ -1,7 +1,14 @@
-/* $NetBSD: msg_125.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
+/* $NetBSD: msg_125.c,v 1.2 2021/01/09 14:37:16 rillig Exp $ */
# 3 "msg_125.c"
// Test for message: ANSI C forbids ordered comparisons of pointers to functions [125]
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -s */
+
+typedef void (*action)(void);
+
+int
+less(action a, action b)
+{
+ return a < b;
+}
diff -r 8a294b059c34 -r 1fe50431f9f2 tests/usr.bin/xlint/lint1/msg_125.exp
--- a/tests/usr.bin/xlint/lint1/msg_125.exp Sat Jan 09 14:33:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_125.exp Sat Jan 09 14:37:16 2021 +0000
@@ -1,1 +1,1 @@
-msg_125.c(6): syntax error ':' [249]
+msg_125.c(13): warning: ANSI C forbids ordered comparisons of pointers to functions [125]
diff -r 8a294b059c34 -r 1fe50431f9f2 tests/usr.bin/xlint/lint1/msg_127.c
--- a/tests/usr.bin/xlint/lint1/msg_127.c Sat Jan 09 14:33:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_127.c Sat Jan 09 14:37:16 2021 +0000
@@ -1,7 +1,13 @@
-/* $NetBSD: msg_127.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */
+/* $NetBSD: msg_127.c,v 1.2 2021/01/09 14:37:16 rillig Exp $ */
# 3 "msg_127.c"
-// Test for message: '&' before array or function: ignored [127]
+/* Test for message: '&' before array or function: ignored [127] */
+
+/* lint1-extra-flags: -t */
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void
+example(void)
+{
+ if (&example != (void *)0)
+ return;
+}
diff -r 8a294b059c34 -r 1fe50431f9f2 tests/usr.bin/xlint/lint1/msg_127.exp
--- a/tests/usr.bin/xlint/lint1/msg_127.exp Sat Jan 09 14:33:53 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_127.exp Sat Jan 09 14:37:16 2021 +0000
@@ -1,1 +1,9 @@
-msg_127.c(6): syntax error ':' [249]
+(1): warning: 'long double' is illegal in traditional C [266]
+(1): warning: function prototypes are illegal in traditional C [270]
+(2): warning: 'long double' is illegal in traditional C [266]
+(2): warning: function prototypes are illegal in traditional C [270]
+(3): warning: 'long double' is illegal in traditional C [266]
+(3): warning: 'long double' is illegal in traditional C [266]
+(3): warning: function prototypes are illegal in traditional C [270]
+msg_127.c(10): warning: function prototypes are illegal in traditional C [270]
+msg_127.c(11): warning: '&' before array or function: ignored [127]
Home |
Main Index |
Thread Index |
Old Index