From c0b0c3cff1a7419c1794db1c85007786cab5616d Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Wed, 15 Nov 2023 01:13:22 +0900 Subject: [PATCH 1/3] Silence compiler warning --- template/bison/yacc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/template/bison/yacc.c b/template/bison/yacc.c index 184eacb3..2d88dee4 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; + (void) yynerrs; /* Silence compiler warning. */ yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */ From 8e462563cd03d7f9286c645909e6db83268a9516 Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Wed, 15 Nov 2023 01:15:37 +0900 Subject: [PATCH 2/3] Remove redundant silence compiler warning --- spec/lrama/integration_spec.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 From 35463e243bd30ced6bc9432d5f6684ae8276779d Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Wed, 15 Nov 2023 11:41:29 +0900 Subject: [PATCH 3/3] Use YY_USE instead of (void) --- template/bison/yacc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/bison/yacc.c b/template/bison/yacc.c index 2d88dee4..0e17b46f 100644 --- a/template/bison/yacc.c +++ b/template/bison/yacc.c @@ -1485,7 +1485,7 @@ YYLTYPE yylloc = yyloc_default; <%# b4_declare_parser_state_variables -%> /* Number of syntax errors so far. */ int yynerrs = 0; - (void) yynerrs; /* Silence compiler warning. */ + YY_USE (yynerrs); /* Silence compiler warning. */ yy_state_fast_t yystate = 0; /* Number of tokens to shift before error messages enabled. */