Thu Jul 8 20:11:15 2021 UTC ()
tests/lint: test error recovery of the parser


(rillig)
diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_249.c

cvs diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_249.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_249.c 2021/07/08 18:02:22 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_249.c 2021/07/08 20:11:15 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: msg_249.c,v 1.4 2021/07/08 18:02:22 rillig Exp $ */ 1/* $NetBSD: msg_249.c,v 1.5 2021/07/08 20:11:15 rillig Exp $ */
2# 3 "msg_249.c" 2# 3 "msg_249.c"
3 3
4// Test for message: syntax error '%s' [249] 4// Test for message: syntax error '%s' [249]
5 5
6/* 6/*
7 * Cover the grammar rule 'top_level_declaration: error T_SEMI'. 7 * Cover the grammar rule 'top_level_declaration: error T_SEMI'.
8 */ 8 */
9/* expect+1: syntax error '"' [249] */ 9/* expect+1: syntax error '"' [249] */
10"syntax error in top_level_declaration"; 10"syntax error in top_level_declaration";
11 11
12/* XXX: This is necessary to recover the yacc parser. */ 12/* XXX: This is necessary to recover the yacc parser. */
13int recover_from_semi; 13int recover_from_semi;
14 14
@@ -23,15 +23,25 @@ int recover_from_rbrace; @@ -23,15 +23,25 @@ int recover_from_rbrace;
23 23
24/* 24/*
25 * Before func.c 1.110 from 2021-06-19, lint ran into this: 25 * Before func.c 1.110 from 2021-06-19, lint ran into this:
26 * assertion "cstmt->c_kind == kind" failed in end_control_statement 26 * assertion "cstmt->c_kind == kind" failed in end_control_statement
27 */ 27 */
28void 28void
29function(void) 29function(void)
30{ 30{
31 if (0) 31 if (0)
32 ; 32 ;
33 ); /* expect: syntax error ')' */ 33 ); /* expect: syntax error ')' */
34} 34}
35 35
 36/* XXX: It is unexpected that this error is not detected. */
 37"This syntax error is not detected.";
 38
36/* XXX: This is necessary to recover the yacc parser. */ 39/* XXX: This is necessary to recover the yacc parser. */
37int recover_from_rparen; 40double recover_from_rparen;
 41
 42/* Ensure that the declaration after the syntax error is processed. */
 43double *
 44access_declaration_after_syntax_error(void)
 45{
 46 return &recover_from_rparen;
 47}