Module Name: src Committed By: rillig Date: Sun Jul 25 09:29:20 UTC 2021
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: Makefile Added Files: src/tests/usr.bin/xlint/lint1: parse_stmt_error.c parse_stmt_error.exp parse_stmt_iter_error.c parse_stmt_iter_error.exp Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1092 -r1.1093 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.93 -r1.94 src/tests/usr.bin/xlint/lint1/Makefile cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/parse_stmt_error.c \ src/tests/usr.bin/xlint/lint1/parse_stmt_error.exp \ src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c \ src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1092 src/distrib/sets/lists/tests/mi:1.1093 --- src/distrib/sets/lists/tests/mi:1.1092 Sun Jul 25 08:42:28 2021 +++ src/distrib/sets/lists/tests/mi Sun Jul 25 09:29:20 2021 @@ -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 Index: src/tests/usr.bin/xlint/lint1/Makefile diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.93 src/tests/usr.bin/xlint/lint1/Makefile:1.94 --- src/tests/usr.bin/xlint/lint1/Makefile:1.93 Sun Jul 25 08:42:28 2021 +++ src/tests/usr.bin/xlint/lint1/Makefile Sun Jul 25 09:29:20 2021 @@ -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.c 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 Added files: Index: src/tests/usr.bin/xlint/lint1/parse_stmt_error.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/parse_stmt_error.c:1.1 --- /dev/null Sun Jul 25 09:29:20 2021 +++ src/tests/usr.bin/xlint/lint1/parse_stmt_error.c Sun Jul 25 09:29:20 2021 @@ -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] */ + ]; +} Index: src/tests/usr.bin/xlint/lint1/parse_stmt_error.exp diff -u /dev/null src/tests/usr.bin/xlint/lint1/parse_stmt_error.exp:1.1 --- /dev/null Sun Jul 25 09:29:20 2021 +++ src/tests/usr.bin/xlint/lint1/parse_stmt_error.exp Sun Jul 25 09:29:20 2021 @@ -0,0 +1,2 @@ +parse_stmt_error.c(17): error: syntax error ']' [249] +parse_stmt_error.c(25): error: syntax error ']' [249] Index: src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c diff -u /dev/null src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c:1.1 --- /dev/null Sun Jul 25 09:29:20 2021 +++ src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c Sun Jul 25 09:29:20 2021 @@ -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] */ + ]; +} Index: src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp diff -u /dev/null src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp:1.1 --- /dev/null Sun Jul 25 09:29:20 2021 +++ src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.exp Sun Jul 25 09:29:20 2021 @@ -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]