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: test messages 268 to 274



details:   https://anonhg.NetBSD.org/src/rev/9870dd3a8917
branches:  trunk
changeset: 1023072:9870dd3a8917
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 22 13:45:56 2021 +0000

description:
tests/lint: test messages 268 to 274

diffstat:

 tests/usr.bin/xlint/lint1/msg_268.c   |  12 +++++++++---
 tests/usr.bin/xlint/lint1/msg_268.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_269.c   |   6 +++---
 tests/usr.bin/xlint/lint1/msg_269.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_270.c   |  14 ++++++++++----
 tests/usr.bin/xlint/lint1/msg_270.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_271.c   |  28 ++++++++++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_271.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_272.c   |   5 ++---
 tests/usr.bin/xlint/lint1/msg_272.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_273.c   |  15 +++++++++++----
 tests/usr.bin/xlint/lint1/msg_273.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_274.c   |  24 ++++++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_274.exp |   2 +-
 14 files changed, 86 insertions(+), 32 deletions(-)

diffs (198 lines):

diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_268.c
--- a/tests/usr.bin/xlint/lint1/msg_268.c       Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_268.c       Sun Aug 22 13:45:56 2021 +0000
@@ -1,7 +1,13 @@
-/*     $NetBSD: msg_268.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_268.c,v 1.3 2021/08/22 13:45:56 rillig Exp $       */
 # 3 "msg_268.c"
 
 // Test for message: variable declared inline: %s [268]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+int
+example(int arg)
+{
+       /* expect+1: warning: variable declared inline: local [268] */
+       inline int local = arg;
+
+       return local;
+}
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_268.exp
--- a/tests/usr.bin/xlint/lint1/msg_268.exp     Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_268.exp     Sun Aug 22 13:45:56 2021 +0000
@@ -1,1 +1,1 @@
-msg_268.c(6): error: syntax error ':' [249]
+msg_268.c(10): warning: variable declared inline: local [268]
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_269.c
--- a/tests/usr.bin/xlint/lint1/msg_269.c       Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_269.c       Sun Aug 22 13:45:56 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_269.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_269.c,v 1.3 2021/08/22 13:45:56 rillig Exp $       */
 # 3 "msg_269.c"
 
 // Test for message: argument declared inline: %s [269]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: argument declared inline: x [269] */
+void example(inline int x);
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_269.exp
--- a/tests/usr.bin/xlint/lint1/msg_269.exp     Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_269.exp     Sun Aug 22 13:45:56 2021 +0000
@@ -1,1 +1,1 @@
-msg_269.c(6): error: syntax error ':' [249]
+msg_269.c(7): warning: argument declared inline: x [269]
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_270.c
--- a/tests/usr.bin/xlint/lint1/msg_270.c       Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_270.c       Sun Aug 22 13:45:56 2021 +0000
@@ -1,7 +1,13 @@
-/*     $NetBSD: msg_270.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_270.c,v 1.3 2021/08/22 13:45:56 rillig Exp $       */
 # 3 "msg_270.c"
 
-// Test for message: function prototypes are illegal in traditional C [270]
+/* Test for message: function prototypes are illegal in traditional C [270] */
+
+/* lint1-flags: -tw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: function prototypes are illegal in traditional C [270] */
+void prototype(void);
+
+char *traditional();
+
+traditional_implicit_int();
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_270.exp
--- a/tests/usr.bin/xlint/lint1/msg_270.exp     Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_270.exp     Sun Aug 22 13:45:56 2021 +0000
@@ -1,1 +1,1 @@
-msg_270.c(6): error: syntax error ':' [249]
+msg_270.c(9): warning: function prototypes are illegal in traditional C [270]
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_271.c
--- a/tests/usr.bin/xlint/lint1/msg_271.c       Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_271.c       Sun Aug 22 13:45:56 2021 +0000
@@ -1,7 +1,27 @@
-/*     $NetBSD: msg_271.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_271.c,v 1.3 2021/08/22 13:45:56 rillig Exp $       */
 # 3 "msg_271.c"
 
-// Test for message: switch expression must be of type `int' in traditional C [271]
+/* Test for message: switch expression must be of type `int' in traditional C [271] */
+
+/* lint1-flags: -tw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+example(long_int, unsigned_int)
+       long long_int;
+       unsigned unsigned_int;
+{
+       /* expect+1: warning: switch expression must be of type `int' in traditional C [271] */
+       switch (long_int) {
+       case 3:
+               return 1;
+       }
+
+       /*
+        * XXX: K&R clearly says "the result must be 'int'", but lint also
+        * allows unsigned int.
+        */
+       switch (unsigned_int) {
+       case 3:
+               return 1;
+       }
+       return 2;
+}
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_271.exp
--- a/tests/usr.bin/xlint/lint1/msg_271.exp     Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_271.exp     Sun Aug 22 13:45:56 2021 +0000
@@ -1,1 +1,1 @@
-msg_271.c(6): error: syntax error ':' [249]
+msg_271.c(13): warning: switch expression must be of type `int' in traditional C [271]
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_272.c
--- a/tests/usr.bin/xlint/lint1/msg_272.c       Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_272.c       Sun Aug 22 13:45:56 2021 +0000
@@ -1,7 +1,6 @@
-/*     $NetBSD: msg_272.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_272.c,v 1.3 2021/08/22 13:45:56 rillig Exp $       */
 # 3 "msg_272.c"
 
 // Test for message: empty translation unit [272]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: empty translation unit [272] */
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_272.exp
--- a/tests/usr.bin/xlint/lint1/msg_272.exp     Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_272.exp     Sun Aug 22 13:45:56 2021 +0000
@@ -1,1 +1,1 @@
-msg_272.c(6): error: syntax error ':' [249]
+msg_272.c(7): warning: empty translation unit [272]
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_273.c
--- a/tests/usr.bin/xlint/lint1/msg_273.c       Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_273.c       Sun Aug 22 13:45:56 2021 +0000
@@ -1,7 +1,14 @@
-/*     $NetBSD: msg_273.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_273.c,v 1.3 2021/08/22 13:45:56 rillig Exp $       */
 # 3 "msg_273.c"
 
-// Test for message: bit-field type '%s' invalid in ANSI C [273]
+/* Test for message: bit-field type '%s' invalid in ANSI C [273] */
+
+/* lint1-flags: -sw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+struct bit_fields {
+       int plain_int: 3;
+       unsigned int unsigned_int: 3;
+       signed int signed_int: 3;
+       /* expect+1: warning: bit-field type 'unsigned char' invalid in ANSI C [273] */
+       unsigned char unsigned_char: 3;
+};
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_273.exp
--- a/tests/usr.bin/xlint/lint1/msg_273.exp     Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_273.exp     Sun Aug 22 13:45:56 2021 +0000
@@ -1,1 +1,1 @@
-msg_273.c(6): error: syntax error ':' [249]
+msg_273.c(13): warning: bit-field type 'unsigned char' invalid in ANSI C [273]
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_274.c
--- a/tests/usr.bin/xlint/lint1/msg_274.c       Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_274.c       Sun Aug 22 13:45:56 2021 +0000
@@ -1,7 +1,23 @@
-/*     $NetBSD: msg_274.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_274.c,v 1.3 2021/08/22 13:45:56 rillig Exp $       */
 # 3 "msg_274.c"
 
-// Test for message: ANSI C forbids comparison of %s with %s [274]
+/* Test for message: ANSI C forbids comparison of %s with %s [274] */
+
+/* lint1-flags: -sw */
+
+void
+example(void (*function_pointer)(void), void *void_pointer)
+{
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+       /* Comparing a function pointer with a null pointer is OK. */
+       if (function_pointer == (void *)0)
+               return;
+
+       /* Comparing a function pointer with a null pointer is OK. */
+       if (function_pointer == (const void *)0)
+               return;
+
+       /* expect+1: warning: ANSI C forbids comparison of function pointer with 'void *' [274] */
+       if (function_pointer == void_pointer)
+               return;
+}
diff -r 3b097d06d7f5 -r 9870dd3a8917 tests/usr.bin/xlint/lint1/msg_274.exp
--- a/tests/usr.bin/xlint/lint1/msg_274.exp     Sun Aug 22 13:21:48 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_274.exp     Sun Aug 22 13:45:56 2021 +0000
@@ -1,1 +1,1 @@
-msg_274.c(6): error: syntax error ':' [249]
+msg_274.c(21): warning: ANSI C forbids comparison of function pointer with 'void *' [274]



Home | Main Index | Thread Index | Old Index