Suppress unused-but-set-variable warning in parsers

This is very ugly: Bison provides a yynerrs variable, which is
usually not actually used, but also not annotated with
YY_MAYBE_UNUSED. Suppress this warning by adding a (void)yynerrs
into the top-level reduction action. The alternative would be to
disable the warning for these generated files.
This commit is contained in:
Nikita Popov 2022-07-28 22:13:57 +02:00
parent 04f5da4b77
commit 107ad28350
4 changed files with 4 additions and 3 deletions

View file

@ -308,7 +308,7 @@ static void zval_ini_dtor(zval *zv)
statement_list: statement_list:
statement_list statement statement_list statement
| %empty | %empty { (void) ini_nerrs; }
; ;
statement: statement:

View file

@ -292,7 +292,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%% /* Rules */ %% /* Rules */
start: start:
top_statement_list { CG(ast) = $1; } top_statement_list { CG(ast) = $1; (void) zendnerrs; }
; ;
reserved_non_modifiers: reserved_non_modifiers:

View file

@ -80,6 +80,7 @@ start:
{ {
ZVAL_COPY_VALUE(&$$, &$1); ZVAL_COPY_VALUE(&$$, &$1);
ZVAL_COPY_VALUE(parser->return_value, &$1); ZVAL_COPY_VALUE(parser->return_value, &$1);
(void) php_json_yynerrs;
YYACCEPT; YYACCEPT;
} }
; ;

View file

@ -66,7 +66,7 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg)
input input
: command { $$ = $1; } : command { $$ = $1; }
| input T_SEPARATOR command { phpdbg_stack_separate($1.top); $$ = $3; } | input T_SEPARATOR command { phpdbg_stack_separate($1.top); $$ = $3; }
| %empty | %empty { (void) phpdbg_nerrs; }
; ;
command command