Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: test parse errors in statements
details: https://anonhg.NetBSD.org/src/rev/3383357679b5
branches: trunk
changeset: 1022561:3383357679b5
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jul 25 09:29:20 2021 +0000
description:
tests/lint: test parse errors in statements
These errors are really unrealistic. Most parse errors that occur in
statements are already handled elsewhere and continue with the next
semicolon.
The tests had to be split into two separate files because lint assumes
that after the 5th parse error, it does not make sense to continue this
translation unit.
diffstat:
distrib/sets/lists/tests/mi | 6 +++-
tests/usr.bin/xlint/lint1/Makefile | 6 +++-
tests/usr.bin/xlint/lint1/parse_stmt_error.c | 26 +++++++++++++++++
tests/usr.bin/xlint/lint1/parse_stmt_error.exp | 2 +
tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c | 32 +++++++++++++++++++++
tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp | 3 +
6 files changed, 73 insertions(+), 2 deletions(-)
diffs (119 lines):
diff -r da58c42a7c4f -r 3383357679b5 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jul 25 08:52:03 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jul 25 09:29:20 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1092 2021/07/25 08:42:28 rillig Exp $
+# $NetBSD: mi,v 1.1093 2021/07/25 09:29:20 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6990,6 +6990,10 @@
./usr/tests/usr.bin/xlint/lint1/op_colon.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/parse_stmt_error.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/parse_stmt_error.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/parse_type_name.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/parse_type_name.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/stmt_for.c tests-usr.bin-tests compattestfile,atf
diff -r da58c42a7c4f -r 3383357679b5 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sun Jul 25 08:52:03 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sun Jul 25 09:29:20 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.93 2021/07/25 08:42:28 rillig Exp $
+# $NetBSD: Makefile,v 1.94 2021/07/25 09:29:20 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 345 # see lint1/err.c
@@ -196,6 +196,10 @@
FILES+= op_colon.exp
FILES+= op_shl_lp64.c
FILES+= op_shl_lp64.exp
+FILES+= parse_stmt_error.c
+FILES+= parse_stmt_error.exp
+FILES+= parse_stmt_iter_error.c
+FILES+= parse_stmt_iter_error.exp
FILES+= parse_type_name.c
FILES+= parse_type_name.exp
FILES+= stmt_for.c
diff -r da58c42a7c4f -r 3383357679b5 tests/usr.bin/xlint/lint1/parse_stmt_error.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_stmt_error.c Sun Jul 25 09:29:20 2021 +0000
@@ -0,0 +1,26 @@
+/* $NetBSD: parse_stmt_error.c,v 1.1 2021/07/25 09:29:20 rillig Exp $ */
+# 3 "parse_stmt_error.c"
+
+/*
+ * Test parsing of errors in selection statements (if, switch).
+ */
+
+void do_nothing(void);
+
+void
+cover_selection_statement_else(_Bool cond)
+{
+ if (cond)
+ do_nothing();
+ else
+ /* expect+1: syntax error ']' [249] */
+ ];
+}
+
+void
+cover_selection_statement_switch(int x)
+{
+ switch (x)
+ /* expect+1: syntax error ']' [249] */
+ ];
+}
diff -r da58c42a7c4f -r 3383357679b5 tests/usr.bin/xlint/lint1/parse_stmt_error.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_stmt_error.exp Sun Jul 25 09:29:20 2021 +0000
@@ -0,0 +1,2 @@
+parse_stmt_error.c(17): error: syntax error ']' [249]
+parse_stmt_error.c(25): error: syntax error ']' [249]
diff -r da58c42a7c4f -r 3383357679b5 tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c Sun Jul 25 09:29:20 2021 +0000
@@ -0,0 +1,32 @@
+/* $NetBSD: parse_stmt_iter_error.c,v 1.1 2021/07/25 09:29:20 rillig Exp $ */
+# 3 "parse_stmt_iter_error.c"
+
+/*
+ * Test parsing of errors in iteration statements (while, do, for).
+ */
+
+void do_nothing(void);
+
+void
+cover_iteration_statement_while(_Bool cond)
+{
+ while (cond)
+ /* expect+1: syntax error ']' [249] */
+ ];
+}
+
+void
+cover_iteration_statement_do(void)
+{
+ do
+ /* expect+1: syntax error ']' [249] */
+ ];
+}
+
+void
+cover_iteration_statement_for(void)
+{
+ for (int i = 0; i < 10; i++)
+ /* expect+1: syntax error ']' [249] */
+ ];
+}
diff -r da58c42a7c4f -r 3383357679b5 tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp Sun Jul 25 09:29:20 2021 +0000
@@ -0,0 +1,3 @@
+parse_stmt_iter_error.c(15): error: syntax error ']' [249]
+parse_stmt_iter_error.c(23): error: syntax error ']' [249]
+parse_stmt_iter_error.c(31): error: syntax error ']' [249]
Home |
Main Index |
Thread Index |
Old Index