summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2021-07-08 05:18:49 +0000
committerrillig <rillig@NetBSD.org>2021-07-08 05:18:49 +0000
commit850cc651bbc84556cfd12dbadef764e4e2d812a4 (patch)
tree8d619ed55f941e48011a68df45cefccd1a03b210
parent6976f3744ab745549dd0c8b715423811ed0f133a (diff)
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.
-rw-r--r--distrib/sets/lists/tests/mi8
-rw-r--r--tests/usr.bin/xlint/lint1/Makefile8
-rw-r--r--tests/usr.bin/xlint/lint1/msg_000_c90.c13
-rw-r--r--tests/usr.bin/xlint/lint1/msg_000_c90.exp1
-rw-r--r--tests/usr.bin/xlint/lint1/msg_001_c90.c14
-rw-r--r--tests/usr.bin/xlint/lint1/msg_001_c90.exp1
-rw-r--r--tests/usr.bin/xlint/lint1/msg_002.c8
-rw-r--r--tests/usr.bin/xlint/lint1/msg_002.exp3
-rw-r--r--tests/usr.bin/xlint/lint1/msg_072.c8
-rw-r--r--tests/usr.bin/xlint/lint1/msg_072.exp3
-rw-r--r--tests/usr.bin/xlint/lint1/msg_272_c90.c13
-rw-r--r--tests/usr.bin/xlint/lint1/msg_272_c90.exp1
12 files changed, 73 insertions, 8 deletions
diff --git a/distrib/sets/lists/tests/mi b/distrib/sets/lists/tests/mi
index e0ad11b3a43..6c1ab9119de 100644
--- a/distrib/sets/lists/tests/mi
+++ b/distrib/sets/lists/tests/mi
@@ -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 --git a/tests/usr.bin/xlint/lint1/Makefile b/tests/usr.bin/xlint/lint1/Makefile
index ce79fd0c4e8..2299dd94ee5 100644
--- a/tests/usr.bin/xlint/lint1/Makefile
+++ b/tests/usr.bin/xlint/lint1/Makefile
@@ -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_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+= 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 --git a/tests/usr.bin/xlint/lint1/msg_000_c90.c b/tests/usr.bin/xlint/lint1/msg_000_c90.c
new file mode 100644
index 00000000000..fa01699d043
--- /dev/null
+++ b/tests/usr.bin/xlint/lint1/msg_000_c90.c
@@ -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 --git a/tests/usr.bin/xlint/lint1/msg_000_c90.exp b/tests/usr.bin/xlint/lint1/msg_000_c90.exp
new file mode 100644
index 00000000000..2019f53101e
--- /dev/null
+++ b/tests/usr.bin/xlint/lint1/msg_000_c90.exp
@@ -0,0 +1 @@
+msg_000_c90.c(13): error: empty declaration [0]
diff --git a/tests/usr.bin/xlint/lint1/msg_001_c90.c b/tests/usr.bin/xlint/lint1/msg_001_c90.c
new file mode 100644
index 00000000000..0c99dd46229
--- /dev/null
+++ b/tests/usr.bin/xlint/lint1/msg_001_c90.c
@@ -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 --git a/tests/usr.bin/xlint/lint1/msg_001_c90.exp b/tests/usr.bin/xlint/lint1/msg_001_c90.exp
new file mode 100644
index 00000000000..03c9bd7a86b
--- /dev/null
+++ b/tests/usr.bin/xlint/lint1/msg_001_c90.exp
@@ -0,0 +1 @@
+msg_001_c90.c(14): error: old style declaration; add 'int' [1]
diff --git a/tests/usr.bin/xlint/lint1/msg_002.c b/tests/usr.bin/xlint/lint1/msg_002.c
index e04bd17c21f..ff06c78cab1 100644
--- a/tests/usr.bin/xlint/lint1/msg_002.c
+++ b/tests/usr.bin/xlint/lint1/msg_002.c
@@ -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 --git a/tests/usr.bin/xlint/lint1/msg_002.exp b/tests/usr.bin/xlint/lint1/msg_002.exp
index d1c4c42229e..55f67601800 100644
--- a/tests/usr.bin/xlint/lint1/msg_002.exp
+++ b/tests/usr.bin/xlint/lint1/msg_002.exp
@@ -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 --git a/tests/usr.bin/xlint/lint1/msg_072.c b/tests/usr.bin/xlint/lint1/msg_072.c
index d114670d0ff..1cc519800f3 100644
--- a/tests/usr.bin/xlint/lint1/msg_072.c
+++ b/tests/usr.bin/xlint/lint1/msg_072.c
@@ -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 --git a/tests/usr.bin/xlint/lint1/msg_072.exp b/tests/usr.bin/xlint/lint1/msg_072.exp
index cc30a6022c2..6f66e1ad6e8 100644
--- a/tests/usr.bin/xlint/lint1/msg_072.exp
+++ b/tests/usr.bin/xlint/lint1/msg_072.exp
@@ -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 --git a/tests/usr.bin/xlint/lint1/msg_272_c90.c b/tests/usr.bin/xlint/lint1/msg_272_c90.c
new file mode 100644
index 00000000000..6bd956e0ca7
--- /dev/null
+++ b/tests/usr.bin/xlint/lint1/msg_272_c90.c
@@ -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 --git a/tests/usr.bin/xlint/lint1/msg_272_c90.exp b/tests/usr.bin/xlint/lint1/msg_272_c90.exp
new file mode 100644
index 00000000000..a45698c09b6
--- /dev/null
+++ b/tests/usr.bin/xlint/lint1/msg_272_c90.exp
@@ -0,0 +1 @@
+msg_272_c90.c(14): error: empty translation unit [272]