Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src tests/lint: add tests for a few early messages



details:   https://anonhg.NetBSD.org/src/rev/acc9f10bbf60
branches:  trunk
changeset: 364672:acc9f10bbf60
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Apr 05 23:09:19 2022 +0000

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

diffstat:

 distrib/sets/lists/tests/mi           |   4 ++--
 tests/usr.bin/xlint/lint1/Makefile    |   4 ++--
 tests/usr.bin/xlint/lint1/msg_018.c   |   7 ++++---
 tests/usr.bin/xlint/lint1/msg_018.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_022.c   |   8 ++++----
 tests/usr.bin/xlint/lint1/msg_022.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_026.c   |   7 ++++---
 tests/usr.bin/xlint/lint1/msg_026.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_027.c   |   9 ++++++++-
 tests/usr.bin/xlint/lint1/msg_027.exp |   1 +
 tests/usr.bin/xlint/lint1/msg_028.c   |  16 +++++++++++++---
 tests/usr.bin/xlint/lint1/msg_028.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_030.c   |  25 +++++++++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_030.exp |   4 +++-
 tests/usr.bin/xlint/lint1/msg_032.c   |  11 ++++++++---
 tests/usr.bin/xlint/lint1/msg_032.exp |   4 +++-
 tests/usr.bin/xlint/lint1/msg_039.c   |  14 ++++++++++----
 tests/usr.bin/xlint/lint1/msg_039.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_040.c   |   8 +++++---
 tests/usr.bin/xlint/lint1/msg_040.exp |   1 -
 20 files changed, 96 insertions(+), 40 deletions(-)

diffs (285 lines):

diff -r 73b8da19d42c -r acc9f10bbf60 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Apr 05 15:59:22 2022 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Apr 05 23:09:19 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1189 2022/03/28 20:52:17 christos Exp $
+# $NetBSD: mi,v 1.1190 2022/04/05 23:09:19 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6626,7 +6626,7 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_039.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_039.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_040.c                      tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/msg_040.exp                    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_040.exp                    tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_041.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_041.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_042.c                      tests-usr.bin-tests     compattestfile,atf
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Tue Apr 05 23:09:19 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.117 2021/12/20 19:48:05 rillig Exp $
+# $NetBSD: Makefile,v 1.118 2022/04/05 23:09:19 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   348             # see lint1/err.c
@@ -216,7 +216,7 @@
 FILES+=                lex_wide_char.exp
 FILES+=                lex_wide_string.c
 FILES+=                lex_wide_string.exp
-FILES+=                ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_176.exp}
+FILES+=                ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_040.exp:Nmsg_176.exp}
 FILES+=                msg_001_c90.c
 FILES+=                msg_001_c90.exp
 FILES+=                msg_000_c90.c
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_018.c
--- a/tests/usr.bin/xlint/lint1/msg_018.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_018.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_018.c,v 1.3 2021/08/26 19:23:25 rillig Exp $       */
+/*     $NetBSD: msg_018.c,v 1.4 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_018.c"
 
 // Test for message: illegal use of 'void' [18]
@@ -9,5 +9,6 @@
 /* expect+1: error: cannot take size/alignment of void [146] */
 unsigned long sizeof_void = sizeof(void);
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+2: error: illegal use of 'void' [18] */
+/* expect+1: warning: empty array declaration: void_array [190] */
+void void_array[];
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_018.exp
--- a/tests/usr.bin/xlint/lint1/msg_018.exp     Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_018.exp     Tue Apr 05 23:09:19 2022 +0000
@@ -1,3 +1,4 @@
 msg_018.c(7): error: void type for 'x' [19]
 msg_018.c(10): error: cannot take size/alignment of void [146]
-msg_018.c(12): error: syntax error ':' [249]
+msg_018.c(14): error: illegal use of 'void' [18]
+msg_018.c(14): warning: empty array declaration: void_array [190]
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_022.c
--- a/tests/usr.bin/xlint/lint1/msg_022.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_022.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_022.c,v 1.3 2022/04/02 20:12:46 rillig Exp $       */
+/*     $NetBSD: msg_022.c,v 1.4 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_022.c"
 
 // Test for message: incomplete or misplaced function definition [22]
@@ -25,6 +25,6 @@
 /* expect+1: warning: empty declaration [0] */
 ;
 
-/* expect+1: error: syntax error ':' [249] */
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+/* expect+2: error: incomplete or misplaced function definition [22] */
+/* expect+1: warning: old style declaration; add 'int' [1] */
+old_style(arg);
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_022.exp
--- a/tests/usr.bin/xlint/lint1/msg_022.exp     Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_022.exp     Tue Apr 05 23:09:19 2022 +0000
@@ -2,4 +2,5 @@
 msg_022.c(15): warning: empty declaration [0]
 msg_022.c(22): error: syntax error 'param1' [249]
 msg_022.c(26): warning: empty declaration [0]
-msg_022.c(29): error: syntax error ':' [249]
+msg_022.c(30): error: incomplete or misplaced function definition [22]
+msg_022.c(30): warning: old style declaration; add 'int' [1]
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_026.c
--- a/tests/usr.bin/xlint/lint1/msg_026.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_026.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: msg_026.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_026.c,v 1.3 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_026.c"
 
 // Test for message: cannot initialize extern declaration: %s [26]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: cannot initialize extern declaration: used [26] */
+extern int used = 1;
+int defined = 1;
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_026.exp
--- a/tests/usr.bin/xlint/lint1/msg_026.exp     Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_026.exp     Tue Apr 05 23:09:19 2022 +0000
@@ -1,1 +1,1 @@
-msg_026.c(6): error: syntax error ':' [249]
+msg_026.c(7): warning: cannot initialize extern declaration: used [26]
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_027.c
--- a/tests/usr.bin/xlint/lint1/msg_027.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_027.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_027.c,v 1.5 2021/09/12 16:28:45 rillig Exp $       */
+/*     $NetBSD: msg_027.c,v 1.6 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_027.c"
 
 // Test for message: redeclaration of %s [27]
@@ -7,3 +7,10 @@
 
 /* expect+1: error: redeclaration of 'identifier' with type 'function(void) returning double', expected 'function(void) returning int' [347] */
 extern double identifier(void);
+
+enum {
+       constant,
+       /* expect+1: error: redeclaration of constant [27] */
+       constant,
+       next
+};
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_027.exp
--- a/tests/usr.bin/xlint/lint1/msg_027.exp     Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_027.exp     Tue Apr 05 23:09:19 2022 +0000
@@ -1,1 +1,2 @@
 msg_027.c(9): error: redeclaration of 'identifier' with type 'function(void) returning double', expected 'function(void) returning int' [347]
+msg_027.c(14): error: redeclaration of constant [27]
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_028.c
--- a/tests/usr.bin/xlint/lint1/msg_028.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_028.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,7 +1,17 @@
-/*     $NetBSD: msg_028.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_028.c,v 1.3 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_028.c"
 
 // Test for message: redefinition of %s [28]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+int
+defined(int arg)
+{
+       return arg;
+}
+
+int
+defined(int arg)
+/* expect+1: error: redefinition of defined [28] */
+{
+       return arg;
+}
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_028.exp
--- a/tests/usr.bin/xlint/lint1/msg_028.exp     Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_028.exp     Tue Apr 05 23:09:19 2022 +0000
@@ -1,1 +1,1 @@
-msg_028.c(6): error: syntax error ':' [249]
+msg_028.c(15): error: redefinition of defined [28]
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_030.c
--- a/tests/usr.bin/xlint/lint1/msg_030.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_030.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,7 +1,24 @@
-/*     $NetBSD: msg_030.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_030.c,v 1.3 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_030.c"
 
-// Test for message: redeclaration of %s; ANSI C requires static [30]
+/* Test for message: redeclaration of %s; ANSI C requires static [30] */
+
+/* lint1-flags: -sw */
+
+static a;
+/* expect+1: warning: redeclaration of a; ANSI C requires static [30] */
+int a;
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+static b;
+/* expect+1: warning: redeclaration of b; ANSI C requires static [30] */
+int b = 1;
+
+static c = 1;
+/* expect+1: warning: redeclaration of c; ANSI C requires static [30] */
+int c;
+
+void
+use_variables(void)
+{
+       c = a + b + c;
+}
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_030.exp
--- a/tests/usr.bin/xlint/lint1/msg_030.exp     Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_030.exp     Tue Apr 05 23:09:19 2022 +0000
@@ -1,1 +1,3 @@
-msg_030.c(6): error: syntax error ':' [249]
+msg_030.c(10): warning: redeclaration of a; ANSI C requires static [30]
+msg_030.c(14): warning: redeclaration of b; ANSI C requires static [30]
+msg_030.c(18): warning: redeclaration of c; ANSI C requires static [30]
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_032.c
--- a/tests/usr.bin/xlint/lint1/msg_032.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_032.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,7 +1,12 @@
-/*     $NetBSD: msg_032.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_032.c,v 1.3 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_032.c"
 
 // Test for message: argument type defaults to 'int': %s [32]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+add(a, b, c)
+/* expect+3: warning: argument type defaults to 'int': a [32] */
+/* expect+2: warning: argument type defaults to 'int': b [32] */
+/* expect+1: warning: argument type defaults to 'int': c [32] */
+{
+       return a + b + c;
+}
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_032.exp
--- a/tests/usr.bin/xlint/lint1/msg_032.exp     Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_032.exp     Tue Apr 05 23:09:19 2022 +0000
@@ -1,1 +1,3 @@
-msg_032.c(6): error: syntax error ':' [249]
+msg_032.c(10): warning: argument type defaults to 'int': a [32]
+msg_032.c(10): warning: argument type defaults to 'int': b [32]
+msg_032.c(10): warning: argument type defaults to 'int': c [32]
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_039.c
--- a/tests/usr.bin/xlint/lint1/msg_039.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_039.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,7 +1,13 @@
-/*     $NetBSD: msg_039.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_039.c,v 1.3 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_039.c"
 
-// Test for message: zero sized array in struct is a C99 extension: %s [39]
+/* Test for message: zero sized array in struct is a C99 extension: %s [39] */
+
+/* lint1-flags: -w */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+struct s {
+       /* expect+2: warning: zero sized array is a C99 extension [322] */
+       /* expect+1: warning: zero sized array in struct is a C99 extension: member [39] */
+       char member[0];
+       char member2;
+};
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_039.exp
--- a/tests/usr.bin/xlint/lint1/msg_039.exp     Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_039.exp     Tue Apr 05 23:09:19 2022 +0000
@@ -1,1 +1,2 @@
-msg_039.c(6): error: syntax error ':' [249]
+msg_039.c(11): warning: zero sized array is a C99 extension [322]
+msg_039.c(11): warning: zero sized array in struct is a C99 extension: member [39]
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_040.c
--- a/tests/usr.bin/xlint/lint1/msg_040.c       Tue Apr 05 15:59:22 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_040.c       Tue Apr 05 23:09:19 2022 +0000
@@ -1,7 +1,9 @@
-/*     $NetBSD: msg_040.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_040.c,v 1.3 2022/04/05 23:09:19 rillig Exp $       */
 # 3 "msg_040.c"
 
 // Test for message: unknown size: %s [40]
+/* This message is not used. */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -Sw */
+
+int var;
diff -r 73b8da19d42c -r acc9f10bbf60 tests/usr.bin/xlint/lint1/msg_040.exp
--- a/tests/usr.bin/xlint/lint1/msg_040.exp     Tue Apr 05 15:59:22 2022 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-msg_040.c(6): error: syntax error ':' [249]



Home | Main Index | Thread Index | Old Index