yacc.c, lalr1.cc: fix warnings about yynerrs

Most often yynerrs is not used.  Clang 15 now complains about such
variables.  Bison itself does not compile:

```
src/parse-gram.c:1797:9: error: variable 'gram_nerrs' set but not used [-Werror,-Wunused-but-set-variable]
    int yynerrs = 0;
        ^
src/parse-gram.c:79:25: note: expanded from macro 'yynerrs'
                        ^
1 error generated.
```

Reported by Nikita Popov.
Fixes https://github.com/akimd/bison/issues/89.

* data/skeletons/yacc.c (yynerrs): Flag with YY_ATTRIBUTE_UNUSED.
* data/skeletons/lalr1.cc (yynerrs_): Likewise.
This commit is contained in:
Akim Demaille
2022-08-02 09:07:31 +02:00
parent b7bdf78c18
commit a166d5450e
3 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -46,8 +46,8 @@ Csaba Raduly [email protected]
Dagobert Michelsen [email protected]
Daniel Frużyński [email protected]
Daniel Galloway [email protected]
Daniela Becker [email protected]
Daniel Hagerty [email protected]
Daniela Becker [email protected]
David Barto [email protected]
David J. MacKenzie [email protected]
David Kastrup [email protected]
@@ -143,6 +143,7 @@ Nick Bowler [email protected]
Nicolas Bedon [email protected]
Nicolas Burrus [email protected]
Nicolas Tisserand [email protected]
Nikita Popov [email protected]
Nikki Valen [email protected]
Noah Friedman [email protected]
Odd Arild Olsen [email protected]
@@ -170,7 +171,6 @@ Quoc Peyrot [email protected]
R Blake [email protected]
Raja R Harinath [email protected]
Ralf Wildenhues [email protected]
Ryan [email protected]
Rich Wilson [email protected]
Richard Stallman [email protected]
Rici Lake [email protected]
@@ -179,6 +179,7 @@ Rob Vermaas [email protected]
Robert Anisko [email protected]
Robert Yang [email protected]
Roland Levillain [email protected]
Ryan [email protected]
Satya Kiran Popuri [email protected]
Sebastian Setzer [email protected]
Sebastien Fricker [email protected]
+1 -1
View File
@@ -847,7 +847,7 @@ m4_if(b4_prefix, [yy], [],
int yylen = 0;
// Error handling.
int yynerrs_ = 0;
int yynerrs_ YY_ATTRIBUTE_UNUSED = 0;
int yyerrstatus_ = 0;
/// The lookahead symbol.
+1 -1
View File
@@ -256,7 +256,7 @@ int yynerrs;]])])
m4_define([b4_declare_parser_state_variables],
[b4_pure_if([[
/* Number of syntax errors so far. */
int yynerrs]m4_ifval([$1], [ = 0])[;
int yynerrs YY_ATTRIBUTE_UNUSED]m4_ifval([$1], [ = 0])[;
]])[
yy_state_fast_t yystate]m4_ifval([$1], [ = 0])[;
/* Number of tokens to shift before error messages enabled. */