Skip to content

Commit

Permalink
Merge pull request #3821 from rouault/unused-but-set-variable-wkt
Browse files Browse the repository at this point in the history
Fix -Wunused-but-set-variable with recent clang in bison generated parsers
  • Loading branch information
rouault committed Jul 12, 2023
2 parents ed8f029 + 0f2a227 commit f440bfd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/generate_wkt_parser.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ string(REPLACE "yyerrlab1:" "#endif\nyyerrlab1:" CONTENTS "${CONTENTS}")
string(REPLACE "for (yylen = 0; yystr[yylen]; yylen++)" "for (yylen = 0; yystr && yystr[yylen]; yylen++)" CONTENTS "${CONTENTS}")
string(REPLACE "return yystpcpy (yyres, yystr) - yyres;" "return (YYPTRDIFF_T)(yystpcpy (yyres, yystr) - yyres);" CONTENTS "${CONTENTS}")
string(REPLACE "YYPTRDIFF_T yysize = yyssp - yyss + 1;" "YYPTRDIFF_T yysize = (YYPTRDIFF_T)(yyssp - yyss + 1);" CONTENTS "${CONTENTS}")
string(REPLACE "#define yynerrs pj_wkt1_nerrs" "/* #define yynerrs pj_wkt1_nerrs */" CONTENTS "${CONTENTS}")
string(REPLACE "int yynerrs;" "/* int yynerrs; */" CONTENTS "${CONTENTS}")
string(REPLACE "yynerrs = 0;" "/* yynerrs = 0; */" CONTENTS "${CONTENTS}")
string(REPLACE "++yynerrs;" "/* ++yynerrs; */" CONTENTS "${CONTENTS}")
file(WRITE "${OUT_FILE}" "${CONTENTS}")
8 changes: 4 additions & 4 deletions src/wkt1_generated_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#define yylex pj_wkt1_lex
#define yyerror pj_wkt1_error
#define yydebug pj_wkt1_debug
#define yynerrs pj_wkt1_nerrs
/* #define yynerrs pj_wkt1_nerrs */

/* First part of user prologue. */

Expand Down Expand Up @@ -1315,7 +1315,7 @@ YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);

/* Number of syntax errors so far. */
int yynerrs;
/* int yynerrs; */

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

yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
/* yynerrs = 0; */
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;

Expand Down Expand Up @@ -1604,7 +1604,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
/* ++yynerrs; */
#if ! YYERROR_VERBOSE
yyerror (context, YY_("syntax error"));
#else
Expand Down
6 changes: 3 additions & 3 deletions src/wkt2_generated_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2882,7 +2882,7 @@ YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);

/* Number of syntax errors so far. */
int yynerrs;
/* int yynerrs; */

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

yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
/* yynerrs = 0; */
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;

Expand Down Expand Up @@ -3171,7 +3171,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
/* ++yynerrs; */
#if ! YYERROR_VERBOSE
yyerror (context, YY_("syntax error"));
#else
Expand Down

0 comments on commit f440bfd

Please sign in to comment.