Skip to content

Commit f440bfd

Browse files
authored
Merge pull request OSGeo#3821 from rouault/unused-but-set-variable-wkt
Fix -Wunused-but-set-variable with recent clang in bison generated parsers
2 parents ed8f029 + 0f2a227 commit f440bfd

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/generate_wkt_parser.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ string(REPLACE "yyerrlab1:" "#endif\nyyerrlab1:" CONTENTS "${CONTENTS}")
1515
string(REPLACE "for (yylen = 0; yystr[yylen]; yylen++)" "for (yylen = 0; yystr && yystr[yylen]; yylen++)" CONTENTS "${CONTENTS}")
1616
string(REPLACE "return yystpcpy (yyres, yystr) - yyres;" "return (YYPTRDIFF_T)(yystpcpy (yyres, yystr) - yyres);" CONTENTS "${CONTENTS}")
1717
string(REPLACE "YYPTRDIFF_T yysize = yyssp - yyss + 1;" "YYPTRDIFF_T yysize = (YYPTRDIFF_T)(yyssp - yyss + 1);" CONTENTS "${CONTENTS}")
18+
string(REPLACE "#define yynerrs pj_wkt1_nerrs" "/* #define yynerrs pj_wkt1_nerrs */" CONTENTS "${CONTENTS}")
19+
string(REPLACE "int yynerrs;" "/* int yynerrs; */" CONTENTS "${CONTENTS}")
20+
string(REPLACE "yynerrs = 0;" "/* yynerrs = 0; */" CONTENTS "${CONTENTS}")
21+
string(REPLACE "++yynerrs;" "/* ++yynerrs; */" CONTENTS "${CONTENTS}")
1822
file(WRITE "${OUT_FILE}" "${CONTENTS}")

src/wkt1_generated_parser.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#define yylex pj_wkt1_lex
6969
#define yyerror pj_wkt1_error
7070
#define yydebug pj_wkt1_debug
71-
#define yynerrs pj_wkt1_nerrs
71+
/* #define yynerrs pj_wkt1_nerrs */
7272

7373
/* First part of user prologue. */
7474

@@ -1315,7 +1315,7 @@ YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
13151315
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
13161316

13171317
/* Number of syntax errors so far. */
1318-
int yynerrs;
1318+
/* int yynerrs; */
13191319

13201320
yy_state_fast_t yystate;
13211321
/* Number of tokens to shift before error messages enabled. */
@@ -1369,7 +1369,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
13691369

13701370
yystate = 0;
13711371
yyerrstatus = 0;
1372-
yynerrs = 0;
1372+
/* yynerrs = 0; */
13731373
yychar = YYEMPTY; /* Cause a token to be read. */
13741374
goto yysetstate;
13751375

@@ -1604,7 +1604,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
16041604
/* If not already recovering from an error, report this error. */
16051605
if (!yyerrstatus)
16061606
{
1607-
++yynerrs;
1607+
/* ++yynerrs; */
16081608
#if ! YYERROR_VERBOSE
16091609
yyerror (context, YY_("syntax error"));
16101610
#else

src/wkt2_generated_parser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,7 +2882,7 @@ YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
28822882
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
28832883

28842884
/* Number of syntax errors so far. */
2885-
int yynerrs;
2885+
/* int yynerrs; */
28862886

28872887
yy_state_fast_t yystate;
28882888
/* Number of tokens to shift before error messages enabled. */
@@ -2936,7 +2936,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
29362936

29372937
yystate = 0;
29382938
yyerrstatus = 0;
2939-
yynerrs = 0;
2939+
/* yynerrs = 0; */
29402940
yychar = YYEMPTY; /* Cause a token to be read. */
29412941
goto yysetstate;
29422942

@@ -3171,7 +3171,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
31713171
/* If not already recovering from an error, report this error. */
31723172
if (!yyerrstatus)
31733173
{
3174-
++yynerrs;
3174+
/* ++yynerrs; */
31753175
#if ! YYERROR_VERBOSE
31763176
yyerror (context, YY_("syntax error"));
31773177
#else

0 commit comments

Comments
 (0)