diff --git a/spec/lrama/integration_spec.rb b/spec/lrama/integration_spec.rb index 59c0f8de..aaf20320 100644 --- a/spec/lrama/integration_spec.rb +++ b/spec/lrama/integration_spec.rb @@ -116,7 +116,7 @@ def test_rules(rules, input, expected, command_args: [], debug: false) %% - program : { (void)yynerrs; } + program : /* empty */ | expr { printf("=> %d", $1); } ; expr : NUM @@ -149,7 +149,7 @@ def test_rules(rules, input, expected, command_args: [], debug: false) %% - program : { } + program : /* empty */ ; Grammar @@ -195,7 +195,7 @@ def test_rules(rules, input, expected, command_args: [], debug: false) %% - program : { (void)yynerrs; } + program : /* empty */ | expr { printf("=> %d", $1); } ; expr : NUM @@ -290,8 +290,6 @@ def test_rules(rules, input, expected, command_args: [], debug: false) line: expr { - (void)yynerrs; - printf("line (%d): ", @expr.first_line); print_location(&@expr); @@ -411,7 +409,7 @@ def test_rules(rules, input, expected, command_args: [], debug: false) %% - program : { (void)yynerrs; } + program : /* empty */ | expr { printf("=> %d", $1); } ; @@ -457,7 +455,7 @@ def test_rules(rules, input, expected, command_args: [], debug: false) %% - program : { (void)yynerrs; } + program : /* empty */ | expr { printf("=> %d", $1); } ; expr : NUM diff --git a/template/bison/yacc.c b/template/bison/yacc.c index 184eacb3..0e17b46f 100644 --- a/template/bison/yacc.c +++ b/template/bison/yacc.c @@ -1485,6 +1485,7 @@ YYLTYPE yylloc = yyloc_default; <%# b4_declare_parser_state_variables -%> /* Number of syntax errors so far. */ int yynerrs = 0; + YY_USE (yynerrs); /* Silence compiler warning. */ yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */