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: add tests for a few mo...



details:   https://anonhg.NetBSD.org/src/rev/b54bc61643d4
branches:  trunk
changeset: 1023153:b54bc61643d4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 27 20:16:50 2021 +0000

description:
tests/lint: add tests for a few more messages

diffstat:

 tests/usr.bin/xlint/lint1/msg_020.c   |   6 +++---
 tests/usr.bin/xlint/lint1/msg_020.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_024.c   |  15 ++++++++++++---
 tests/usr.bin/xlint/lint1/msg_024.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_025.c   |   6 +++---
 tests/usr.bin/xlint/lint1/msg_025.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_033.c   |  12 +++++++++---
 tests/usr.bin/xlint/lint1/msg_033.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_038.c   |  10 +++++++---
 tests/usr.bin/xlint/lint1/msg_038.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_049.c   |  28 ++++++++++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_049.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_052.c   |  11 ++++++++---
 tests/usr.bin/xlint/lint1/msg_052.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_053.c   |  11 ++++++++---
 tests/usr.bin/xlint/lint1/msg_053.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_078.c   |   7 ++++---
 tests/usr.bin/xlint/lint1/msg_078.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_079.c   |  13 ++++++++++---
 tests/usr.bin/xlint/lint1/msg_079.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_200.c   |  14 +++++++++++---
 tests/usr.bin/xlint/lint1/msg_200.exp |   2 +-
 22 files changed, 111 insertions(+), 45 deletions(-)

diffs (287 lines):

diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_020.c
--- a/tests/usr.bin/xlint/lint1/msg_020.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_020.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_020.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_020.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_020.c"
 
 // Test for message: negative array dimension (%d) [20]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: error: negative array dimension (-3) [20] */
+int array[-3];
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_020.exp
--- a/tests/usr.bin/xlint/lint1/msg_020.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_020.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_020.c(6): error: syntax error ':' [249]
+msg_020.c(7): error: negative array dimension (-3) [20]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_024.c
--- a/tests/usr.bin/xlint/lint1/msg_024.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_024.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,16 @@
-/*     $NetBSD: msg_024.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_024.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_024.c"
 
 // Test for message: cannot initialize function: %s [24]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+typedef void (function)(void);
+
+void
+definition(void)
+{
+}
+
+/* expect+3: error: cannot initialize function: fn [24] */
+/* The following message is strange but does not occur in practice. */
+/* expect+1: error: {}-enclosed initializer required [181] */
+function fn = definition;
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_024.exp
--- a/tests/usr.bin/xlint/lint1/msg_024.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_024.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,2 @@
-msg_024.c(6): error: syntax error ':' [249]
+msg_024.c(16): error: cannot initialize function: fn [24]
+msg_024.c(16): error: {}-enclosed initializer required [181]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_025.c
--- a/tests/usr.bin/xlint/lint1/msg_025.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_025.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_025.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_025.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_025.c"
 
 // Test for message: cannot initialize typedef: %s [25]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: error: cannot initialize typedef: number [25] */
+typedef int number = 3;
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_025.exp
--- a/tests/usr.bin/xlint/lint1/msg_025.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_025.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_025.c(6): error: syntax error ':' [249]
+msg_025.c(7): error: cannot initialize typedef: number [25]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_033.c
--- a/tests/usr.bin/xlint/lint1/msg_033.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_033.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,13 @@
-/*     $NetBSD: msg_033.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_033.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_033.c"
 
 // Test for message: duplicate member name: %s [33]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -r */
+
+struct {
+       /* Despite the option '-r', this location is not mentioned. */
+       int member;
+       /* expect+1: error: duplicate member name: member [33] */
+       double member;
+};
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_033.exp
--- a/tests/usr.bin/xlint/lint1/msg_033.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_033.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_033.c(6): error: syntax error ':' [249]
+msg_033.c(12): error: duplicate member name: member [33]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_038.c
--- a/tests/usr.bin/xlint/lint1/msg_038.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_038.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,11 @@
-/*     $NetBSD: msg_038.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_038.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_038.c"
 
 // Test for message: function illegal in structure or union [38]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+typedef void (function)(void);
+
+struct {
+       /* expect+1: error: function illegal in structure or union [38] */
+       function fn;
+} s;
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_038.exp
--- a/tests/usr.bin/xlint/lint1/msg_038.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_038.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_038.c(6): error: syntax error ':' [249]
+msg_038.c(10): error: function illegal in structure or union [38]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_049.c
--- a/tests/usr.bin/xlint/lint1/msg_049.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_049.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,27 @@
-/*     $NetBSD: msg_049.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_049.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_049.c"
 
-// Test for message: anonymous struct/union members is a C9X feature [49]
+/* Test for message: anonymous struct/union members is a C9X feature [49] */
+
+/* lint1-flags: -sw */
+
+/*
+ * FIXME: C99 does not allow anonymous struct/union members, that's a GCC
+ * extension that got incorporated into C11.
+ */
+
+struct {
+       unsigned int flag: 1;
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+       /*
+        * This is an anonymous struct/union member, but that's not what
+        * message 49 is about.
+        */
+       unsigned int :0;
+
+       union {
+               int int_value;
+               void *pointer_value;
+       };
+       /* expect-1: warning: anonymous struct/union members is a C9X feature [49] */
+} s;
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_049.exp
--- a/tests/usr.bin/xlint/lint1/msg_049.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_049.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_049.c(6): error: syntax error ':' [249]
+msg_049.c(25): warning: anonymous struct/union members is a C9X feature [49]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_052.c
--- a/tests/usr.bin/xlint/lint1/msg_052.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_052.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,12 @@
-/*     $NetBSD: msg_052.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_052.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_052.c"
 
 // Test for message: cannot initialize parameter: %s [52]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+int
+definition(i)
+       /* expect+1: error: cannot initialize parameter: i [52] */
+       int i = 3;
+{
+       return i;
+}
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_052.exp
--- a/tests/usr.bin/xlint/lint1/msg_052.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_052.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_052.c(6): error: syntax error ':' [249]
+msg_052.c(9): error: cannot initialize parameter: i [52]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_053.c
--- a/tests/usr.bin/xlint/lint1/msg_053.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_053.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,12 @@
-/*     $NetBSD: msg_053.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_053.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_053.c"
 
 // Test for message: declared argument %s is missing [53]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+oldstyle(argument)
+       int argument;
+       /* expect+1: error: declared argument extra_argument is missing [53] */
+       int extra_argument;
+{
+       return argument;
+}
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_053.exp
--- a/tests/usr.bin/xlint/lint1/msg_053.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_053.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_053.c(6): error: syntax error ':' [249]
+msg_053.c(9): error: declared argument extra_argument is missing [53]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_078.c
--- a/tests/usr.bin/xlint/lint1/msg_078.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_078.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: msg_078.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_078.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_078.c"
 
 // Test for message: nonportable character escape [78]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+char either_255_or_minus_1 = '\377';
+/* expect+1: warning: dubious escape \y [79] */
+char dubious_escape = '\y';
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_078.exp
--- a/tests/usr.bin/xlint/lint1/msg_078.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_078.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_078.c(6): error: syntax error ':' [249]
+msg_078.c(8): warning: dubious escape \y [79]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_079.c
--- a/tests/usr.bin/xlint/lint1/msg_079.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_079.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,14 @@
-/*     $NetBSD: msg_079.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_079.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_079.c"
 
 // Test for message: dubious escape \%c [79]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+int my_printf(const char *, ...);
+
+void
+print_color(_Bool red, _Bool green, _Bool blue)
+{
+       /* expect+1: warning: dubious escape \e [79] */
+       my_printf("\e[%dm",
+           30 + (red ? 1 : 0) + (green ? 2 : 0) + (blue ? 4 : 0));
+}
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_079.exp
--- a/tests/usr.bin/xlint/lint1/msg_079.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_079.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_079.c(6): error: syntax error ':' [249]
+msg_079.c(12): warning: dubious escape \e [79]
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_200.c
--- a/tests/usr.bin/xlint/lint1/msg_200.c       Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_200.c       Fri Aug 27 20:16:50 2021 +0000
@@ -1,7 +1,15 @@
-/*     $NetBSD: msg_200.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_200.c,v 1.3 2021/08/27 20:16:50 rillig Exp $       */
 # 3 "msg_200.c"
 
 // Test for message: duplicate case in switch: %lu [200]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void
+example(unsigned x)
+{
+       switch (x) {
+       case 3:
+       /* expect+1: error: duplicate case in switch: 3 [200] */
+       case 3:
+               break;
+       }
+}
diff -r 3c3971d3077d -r b54bc61643d4 tests/usr.bin/xlint/lint1/msg_200.exp
--- a/tests/usr.bin/xlint/lint1/msg_200.exp     Fri Aug 27 19:50:44 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_200.exp     Fri Aug 27 20:16:50 2021 +0000
@@ -1,1 +1,1 @@
-msg_200.c(6): error: syntax error ':' [249]
+msg_200.c(12): error: duplicate case in switch: 3 [200]



Home | Main Index | Thread Index | Old Index