Module Name:    src
Committed By:   rillig
Date:           Sat Jan  9 14:37:16 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_117.c msg_117.exp msg_120.c
            msg_120.exp msg_125.c msg_125.exp msg_127.c msg_127.exp

Log Message:
lint: add tests for messages 117, 120, 125, 127


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_117.c \
    src/tests/usr.bin/xlint/lint1/msg_117.exp \
    src/tests/usr.bin/xlint/lint1/msg_120.c \
    src/tests/usr.bin/xlint/lint1/msg_120.exp \
    src/tests/usr.bin/xlint/lint1/msg_125.c \
    src/tests/usr.bin/xlint/lint1/msg_125.exp \
    src/tests/usr.bin/xlint/lint1/msg_127.c \
    src/tests/usr.bin/xlint/lint1/msg_127.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_117.c
diff -u src/tests/usr.bin/xlint/lint1/msg_117.c:1.1 src/tests/usr.bin/xlint/lint1/msg_117.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_117.c:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.c	Sat Jan  9 14:37:16 2021
@@ -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;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_117.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_117.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_117.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_117.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.exp	Sat Jan  9 14:37:16 2021
@@ -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]
Index: src/tests/usr.bin/xlint/lint1/msg_120.c
diff -u src/tests/usr.bin/xlint/lint1/msg_120.c:1.1 src/tests/usr.bin/xlint/lint1/msg_120.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_120.c:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_120.c	Sat Jan  9 14:37:16 2021
@@ -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;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_120.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_120.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_120.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_120.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_120.exp	Sat Jan  9 14:37:16 2021
@@ -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]
Index: src/tests/usr.bin/xlint/lint1/msg_125.c
diff -u src/tests/usr.bin/xlint/lint1/msg_125.c:1.1 src/tests/usr.bin/xlint/lint1/msg_125.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_125.c:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_125.c	Sat Jan  9 14:37:16 2021
@@ -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;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_125.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_125.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_125.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_125.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_125.exp	Sat Jan  9 14:37:16 2021
@@ -1 +1 @@
-msg_125.c(6): syntax error ':' [249]
+msg_125.c(13): warning: ANSI C forbids ordered comparisons of pointers to functions [125]
Index: src/tests/usr.bin/xlint/lint1/msg_127.c
diff -u src/tests/usr.bin/xlint/lint1/msg_127.c:1.1 src/tests/usr.bin/xlint/lint1/msg_127.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_127.c:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_127.c	Sat Jan  9 14:37:16 2021
@@ -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] */
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -t */
+
+void
+example(void)
+{
+	if (&example != (void *)0)
+		return;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_127.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_127.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_127.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_127.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_127.exp	Sat Jan  9 14:37:16 2021
@@ -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]

Reply via email to