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 C90 mode and malformed declarations



details:   https://anonhg.NetBSD.org/src/rev/86ac6984dfe5
branches:  trunk
changeset: 1022187:86ac6984dfe5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 08 05:18:49 2021 +0000

description:
tests/lint: add tests for C90 mode and malformed declarations

In the grammar, 148 lines are still uncovered by the tests.  The
untested parts are mostly obscure declarations and a few parse errors.

diffstat:

 distrib/sets/lists/tests/mi               |   8 +++++++-
 tests/usr.bin/xlint/lint1/Makefile        |   8 +++++++-
 tests/usr.bin/xlint/lint1/msg_000_c90.c   |  13 +++++++++++++
 tests/usr.bin/xlint/lint1/msg_000_c90.exp |   1 +
 tests/usr.bin/xlint/lint1/msg_001_c90.c   |  14 ++++++++++++++
 tests/usr.bin/xlint/lint1/msg_001_c90.exp |   1 +
 tests/usr.bin/xlint/lint1/msg_002.c       |   8 ++++++--
 tests/usr.bin/xlint/lint1/msg_002.exp     |   3 ++-
 tests/usr.bin/xlint/lint1/msg_072.c       |   8 ++++++--
 tests/usr.bin/xlint/lint1/msg_072.exp     |   3 ++-
 tests/usr.bin/xlint/lint1/msg_272_c90.c   |  13 +++++++++++++
 tests/usr.bin/xlint/lint1/msg_272_c90.exp |   1 +
 12 files changed, 73 insertions(+), 8 deletions(-)

diffs (174 lines):

diff -r d52bb8c15721 -r 86ac6984dfe5 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Thu Jul 08 04:09:10 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Thu Jul 08 05:18:49 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1077 2021/07/06 17:33:07 rillig Exp $
+# $NetBSD: mi,v 1.1078 2021/07/08 05:18:49 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6257,8 +6257,12 @@
 ./usr/tests/usr.bin/xlint/lint1/lex_wide_string.exp            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_000.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_000.exp                    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_000_c90.c                  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_000_c90.exp                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_001.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_001.exp                    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_001_c90.c                  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_001_c90.exp                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_002.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_002.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_003.c                      tests-usr.bin-tests     compattestfile,atf
@@ -6805,6 +6809,8 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_271.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_272.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_272.exp                    tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_272_c90.c                  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_272_c90.exp                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_273.c                      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_273.exp                    tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_274.c                      tests-usr.bin-tests     compattestfile,atf
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Thu Jul 08 04:09:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Thu Jul 08 05:18:49 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.80 2021/07/06 17:33:07 rillig Exp $
+# $NetBSD: Makefile,v 1.81 2021/07/08 05:18:49 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   345             # see lint1/err.c
@@ -157,10 +157,16 @@
 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+=                msg_001_c90.c
+FILES+=                msg_001_c90.exp
+FILES+=                msg_000_c90.c
+FILES+=                msg_000_c90.exp
 FILES+=                msg_230_uchar.c
 FILES+=                msg_230_uchar.exp
 FILES+=                msg_259_ilp32.c
 FILES+=                msg_259_ilp32.exp
+FILES+=                msg_272_c90.c
+FILES+=                msg_272_c90.exp
 FILES+=                op_colon.c
 FILES+=                op_colon.exp
 FILES+=                op_shl_lp64.c
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_000_c90.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_000_c90.c   Thu Jul 08 05:18:49 2021 +0000
@@ -0,0 +1,13 @@
+/*     $NetBSD: msg_000_c90.c,v 1.1 2021/07/08 05:18:49 rillig Exp $   */
+# 3 "msg_000_c90.c"
+
+/*
+ * Test for message: empty declaration [0]
+ *
+ * In strict C90 mode, an empty declaration is an error, not merely a warning.
+ */
+
+/* lint1-flags: -s */
+
+/* expect+1: error: empty declaration [0] */
+;
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_000_c90.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_000_c90.exp Thu Jul 08 05:18:49 2021 +0000
@@ -0,0 +1,1 @@
+msg_000_c90.c(13): error: empty declaration [0]
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_001_c90.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_001_c90.c   Thu Jul 08 05:18:49 2021 +0000
@@ -0,0 +1,14 @@
+/*     $NetBSD: msg_001_c90.c,v 1.1 2021/07/08 05:18:49 rillig Exp $   */
+# 3 "msg_001_c90.c"
+
+/*
+ * Test for message: old style declaration; add 'int' [1]
+ *
+ * In strict C90 mode, an old-style declaration is an error, not merely a
+ * warning.
+ */
+
+/* lint1-flags: -s */
+
+/* expect+1: error: old style declaration; add 'int' [1] */
+implicit_global_variable;
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_001_c90.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_001_c90.exp Thu Jul 08 05:18:49 2021 +0000
@@ -0,0 +1,1 @@
+msg_001_c90.c(14): error: old style declaration; add 'int' [1]
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_002.c
--- a/tests/usr.bin/xlint/lint1/msg_002.c       Thu Jul 08 04:09:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_002.c       Thu Jul 08 05:18:49 2021 +0000
@@ -1,8 +1,12 @@
-/*     $NetBSD: msg_002.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_002.c,v 1.4 2021/07/08 05:18:49 rillig Exp $       */
 # 3 "msg_002.c"
 
 // Test for message: empty declaration [2]
 
-int;                           /* expect: 2 */
+/* expect+1: warning: empty declaration [2] */
+int;
 
 int local_variable;
+
+/* expect+1: warning: empty declaration [2] */
+const;
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_002.exp
--- a/tests/usr.bin/xlint/lint1/msg_002.exp     Thu Jul 08 04:09:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_002.exp     Thu Jul 08 05:18:49 2021 +0000
@@ -1,1 +1,2 @@
-msg_002.c(6): warning: empty declaration [2]
+msg_002.c(7): warning: empty declaration [2]
+msg_002.c(12): warning: empty declaration [2]
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_072.c
--- a/tests/usr.bin/xlint/lint1/msg_072.c       Thu Jul 08 04:09:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_072.c       Thu Jul 08 05:18:49 2021 +0000
@@ -1,8 +1,12 @@
-/*     $NetBSD: msg_072.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_072.c,v 1.4 2021/07/08 05:18:49 rillig Exp $       */
 # 3 "msg_072.c"
 
 // Test for message: typedef declares no type name [72]
 
-typedef int;                   /* expect: 72 */
+/* expect+1: warning: typedef declares no type name [72] */
+typedef int;
 
 typedef int number;
+
+/* expect+1: warning: typedef declares no type name [72] */
+const typedef;
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_072.exp
--- a/tests/usr.bin/xlint/lint1/msg_072.exp     Thu Jul 08 04:09:10 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_072.exp     Thu Jul 08 05:18:49 2021 +0000
@@ -1,1 +1,2 @@
-msg_072.c(6): warning: typedef declares no type name [72]
+msg_072.c(7): warning: typedef declares no type name [72]
+msg_072.c(12): warning: typedef declares no type name [72]
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_272_c90.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_272_c90.c   Thu Jul 08 05:18:49 2021 +0000
@@ -0,0 +1,13 @@
+/*     $NetBSD: msg_272_c90.c,v 1.1 2021/07/08 05:18:49 rillig Exp $   */
+# 3 "msg_272_c90.c"
+
+/*
+ * Test for message: empty translation unit [272]
+ *
+ * In strict C90 mode, an empty translation unit is an error, not merely a
+ * warning.
+ */
+
+/* lint1-flags: -s */
+
+/* expect+1: error: empty translation unit [272] */
diff -r d52bb8c15721 -r 86ac6984dfe5 tests/usr.bin/xlint/lint1/msg_272_c90.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_272_c90.exp Thu Jul 08 05:18:49 2021 +0000
@@ -0,0 +1,1 @@
+msg_272_c90.c(14): error: empty translation unit [272]



Home | Main Index | Thread Index | Old Index