From 107ad28350e76f40d6e65ceac4e45cbf8cc3dc75 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 28 Jul 2022 22:13:57 +0200 Subject: [PATCH] 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. --- Zend/zend_ini_parser.y | 2 +- Zend/zend_language_parser.y | 2 +- ext/json/json_parser.y | 1 + sapi/phpdbg/phpdbg_parser.y | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index 7eb37535207..0091dbbfea8 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -308,7 +308,7 @@ static void zval_ini_dtor(zval *zv) statement_list: statement_list statement - | %empty + | %empty { (void) ini_nerrs; } ; statement: diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 3ce6a38d0d4..5dcda82a366 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -292,7 +292,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %% /* Rules */ start: - top_statement_list { CG(ast) = $1; } + top_statement_list { CG(ast) = $1; (void) zendnerrs; } ; reserved_non_modifiers: diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y index 862b1bc0ab7..90ff0a7c758 100644 --- a/ext/json/json_parser.y +++ b/ext/json/json_parser.y @@ -80,6 +80,7 @@ start: { ZVAL_COPY_VALUE(&$$, &$1); ZVAL_COPY_VALUE(parser->return_value, &$1); + (void) php_json_yynerrs; YYACCEPT; } ; diff --git a/sapi/phpdbg/phpdbg_parser.y b/sapi/phpdbg/phpdbg_parser.y index 3a6ad9833ae..50cb93f05f6 100644 --- a/sapi/phpdbg/phpdbg_parser.y +++ b/sapi/phpdbg/phpdbg_parser.y @@ -66,7 +66,7 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg) input : command { $$ = $1; } | input T_SEPARATOR command { phpdbg_stack_separate($1.top); $$ = $3; } - | %empty + | %empty { (void) phpdbg_nerrs; } ; command