warnings: enable -Wuseless-cast, and eliminate warnings

Prompted by Frank Heckenbach.
https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html.

* configure.ac (warn_cxx): Add -Wuseless-cast.
* data/skeletons/c.m4 (b4_attribute_define): Define
YY_IGNORE_USELESS_CAST_BEGIN and YY_IGNORE_USELESS_CAST_END.
* data/skeletons/glr.c (YY_FPRINTF): New, replaces YYFPRINTF, wrapped
with YY_IGNORE_USELESS_CAST_BEGIN and YY_IGNORE_USELESS_CAST_END.
(YY_DPRINTF): Likewise.
* tests/actions.at: Remove useless cast.
* tests/headers.at: Adjust.
This commit is contained in:
Akim Demaille
2019-11-30 09:23:35 +01:00
parent 9e9e49224f
commit f8d82ff039
7 changed files with 153 additions and 100 deletions

12
TODO
View File

@@ -1,4 +1,16 @@
* Bison 3.5 * Bison 3.5
** Deprecate YYPRINT
The doc shows it too much.
** glr.c: parse.assert
There are many assertions in glr.c that are there to check the skeleton
itself, not the user code. So it should be under the control of
parse.assert.
** java, d: error.verbose
The code checks dynamically for error.verbose. It should be controlled by
M4.
** doc ** doc
I feel its ugly to use the GNU style to declare functions in the doc. It I feel its ugly to use the GNU style to declare functions in the doc. It
generates tons of white space in the page, and may contribute to bad page generates tons of white space in the page, and may contribute to bad page

View File

@@ -151,8 +151,6 @@ if test "$enable_gcc_warnings" = yes; then
# Warnings for the test suite, and maybe for bison if GCC is modern # Warnings for the test suite, and maybe for bison if GCC is modern
# enough. # enough.
gl_WARN_ADD([-Wmissing-declarations], [WARN_CFLAGS_TEST])
gl_WARN_ADD([-Wmissing-prototypes], [WARN_CFLAGS_TEST])
test $lv_cv_gcc_pragma_push_works = yes && test $lv_cv_gcc_pragma_push_works = yes &&
AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"]) AS_VAR_APPEND([WARN_CFLAGS], [" $WARN_CFLAGS_TEST"])
@@ -179,6 +177,14 @@ if test "$enable_gcc_warnings" = yes; then
[[if (sizeof (long) < sizeof (int)) return 1;]])]) [[if (sizeof (long) < sizeof (int)) return 1;]])])
gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS], gl_WARN_ADD([-Wzero-as-null-pointer-constant], [WARN_CXXFLAGS],
[AC_LANG_PROGRAM([], [nullptr])]) [AC_LANG_PROGRAM([], [nullptr])])
# Before GCC6, the pragmas don't work well enough to neutralize
# this warning.
gl_WARN_ADD([-Wuseless-cast], [WARN_CXXFLAGS],
[AC_LANG_PROGRAM([], [
#if defined __GNUC__ && ! defined __ICC && ! defined __clang__ && __GNUC__ < 6
syntax error
#endif
])])
gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS]) gl_WARN_ADD([-Werror], [WERROR_CXXFLAGS])
# Warnings for the test suite only. # Warnings for the test suite only.
for i in $warn_tests; for i in $warn_tests;

View File

@@ -327,11 +327,11 @@ m4_define([b4_attribute_define],
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */ /* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop") _Pragma ("GCC diagnostic pop")
#else #else
# define YY_INITIAL_VALUE(Value) Value # define YY_INITIAL_VALUE(Value) Value
@@ -343,6 +343,18 @@ m4_define([b4_attribute_define],
#ifndef YY_INITIAL_VALUE #ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */ # define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif #endif
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
# define YY_IGNORE_USELESS_CAST_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END \
_Pragma ("GCC diagnostic pop")
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif
]]) ]])

View File

@@ -470,23 +470,36 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
# define YYFPRINTF fprintf # define YYFPRINTF fprintf
# endif # endif
]b4_yy_location_print_define[ # define YY_FPRINTF \
YY_IGNORE_USELESS_CAST_BEGIN YY_FPRINTF_
# define YYDPRINTF(Args) \ # define YY_FPRINTF_(Args) \
do { \
YYFPRINTF Args; \
YY_IGNORE_USELESS_CAST_END \
} while (0)
# define YY_DPRINTF \
YY_IGNORE_USELESS_CAST_BEGIN YY_DPRINTF_
# define YY_DPRINTF_(Args) \
do { \ do { \
if (yydebug) \ if (yydebug) \
YYFPRINTF Args; \ YYFPRINTF Args; \
YY_IGNORE_USELESS_CAST_END \
} while (0) } while (0)
]b4_yy_location_print_define[
]b4_yy_symbol_print_define[ ]b4_yy_symbol_print_define[
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \ do { \
if (yydebug) \ if (yydebug) \
{ \ { \
YYFPRINTF (stderr, "%s ", Title); \ YY_FPRINTF ((stderr, "%s ", Title)); \
yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \ yy_symbol_print (stderr, Type, Value]b4_locuser_args([Location])[); \
YYFPRINTF (stderr, "\n"); \ YY_FPRINTF ((stderr, "\n")); \
} \ } \
} while (0) } while (0)
@@ -502,7 +515,7 @@ static void yypdumpstack (struct yyGLRStack* yystackp)
#else /* !]b4_api_PREFIX[DEBUG */ #else /* !]b4_api_PREFIX[DEBUG */
# define YYDPRINTF(Args) do {} while (yyfalse) # define YY_DPRINTF(Args) do {} while (yyfalse)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
#endif /* !]b4_api_PREFIX[DEBUG */ #endif /* !]b4_api_PREFIX[DEBUG */
@@ -786,7 +799,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
]b4_parse_param_use()dnl ]b4_parse_param_use()dnl
[ if (*yycharp == YYEMPTY) [ if (*yycharp == YYEMPTY)
{ {
YYDPRINTF ((stderr, "Reading a token: "));]b4_glr_cc_if([[ YY_DPRINTF ((stderr, "Reading a token: "));]b4_glr_cc_if([[
#if YY_EXCEPTIONS #if YY_EXCEPTIONS
try try
{ {
@@ -796,7 +809,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
} }
catch (const ]b4_namespace_ref[::]b4_parser_class[::syntax_error& yyexc) catch (const ]b4_namespace_ref[::]b4_parser_class[::syntax_error& yyexc)
{ {
YYDPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([ YY_DPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
yylloc = yyexc.location;])[ yylloc = yyexc.location;])[
yyerror (]b4_lyyerror_args[yyexc.what ()); yyerror (]b4_lyyerror_args[yyexc.what ());
// Map errors caught in the scanner to the undefined token // Map errors caught in the scanner to the undefined token
@@ -810,7 +823,7 @@ yygetToken (int *yycharp][]b4_pure_if([, yyGLRStack* yystackp])[]b4_user_formals
if (*yycharp <= YYEOF) if (*yycharp <= YYEOF)
{ {
*yycharp = yytoken = YYEOF; *yycharp = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n")); YY_DPRINTF ((stderr, "Now at end of input.\n"));
} }
else else
{ {
@@ -892,7 +905,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
} }
catch (const syntax_error& yyexc) catch (const syntax_error& yyexc)
{ {
YYDPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([ YY_DPRINTF ((stderr, "Caught exception: %s\n", yyexc.what()));]b4_locations_if([
*yylocp = yyexc.location;])[ *yylocp = yyexc.location;])[
yyerror (]b4_yyerror_args[yyexc.what ()); yyerror (]b4_yyerror_args[yyexc.what ());
YYERROR; YYERROR;
@@ -946,9 +959,9 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
if (yydebug) if (yydebug)
{ {
if (yys->yysemantics.yyfirstVal) if (yys->yysemantics.yyfirstVal)
YYFPRINTF (stderr, "%s unresolved", yymsg); YY_FPRINTF ((stderr, "%s unresolved", yymsg));
else else
YYFPRINTF (stderr, "%s incomplete", yymsg); YY_FPRINTF ((stderr, "%s incomplete", yymsg));
YY_SYMBOL_PRINT ("", yystos[yys->yylrState], YY_NULLPTR, &yys->yyloc); YY_SYMBOL_PRINT ("", yystos[yys->yylrState], YY_NULLPTR, &yys->yyloc);
} }
#endif #endif
@@ -1258,7 +1271,7 @@ yyundeleteLastStack (yyGLRStack* yystackp)
return; return;
yystackp->yytops.yystates[0] = yystackp->yylastDeleted; yystackp->yytops.yystates[0] = yystackp->yylastDeleted;
yystackp->yytops.yysize = 1; yystackp->yytops.yysize = 1;
YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n")); YY_DPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
yystackp->yylastDeleted = YY_NULLPTR; yystackp->yylastDeleted = YY_NULLPTR;
} }
@@ -1272,7 +1285,7 @@ yyremoveDeletes (yyGLRStack* yystackp)
if (yystackp->yytops.yystates[yyi] == YY_NULLPTR) if (yystackp->yytops.yystates[yyi] == YY_NULLPTR)
{ {
if (yyi == yyj) if (yyi == yyj)
YYDPRINTF ((stderr, "Removing dead stacks.\n")); YY_DPRINTF ((stderr, "Removing dead stacks.\n"));
yystackp->yytops.yysize -= 1; yystackp->yytops.yysize -= 1;
} }
else else
@@ -1286,7 +1299,7 @@ yyremoveDeletes (yyGLRStack* yystackp)
yystackp->yytops.yylookaheadNeeds[yyj] = yystackp->yytops.yylookaheadNeeds[yyj] =
yystackp->yytops.yylookaheadNeeds[yyi]; yystackp->yytops.yylookaheadNeeds[yyi];
if (yyj != yyi) if (yyj != yyi)
YYDPRINTF ((stderr, "Rename stack %ld -> %ld.\n", YY_DPRINTF ((stderr, "Rename stack %ld -> %ld.\n",
YY_CAST (long, yyi), YY_CAST (long, yyj))); YY_CAST (long, yyi), YY_CAST (long, yyj)));
yyj += 1; yyj += 1;
} }
@@ -1356,22 +1369,22 @@ yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk,
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([ int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
int yylow = 1;])[ int yylow = 1;])[
int yyi; int yyi;
YYFPRINTF (stderr, "Reducing stack %ld by rule %d (line %d):\n", YY_FPRINTF ((stderr, "Reducing stack %ld by rule %d (line %d):\n",
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule]); YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule]));
if (! yynormal) if (! yynormal)
yyfillin (yyvsp, 1, -yynrhs); yyfillin (yyvsp, 1, -yynrhs);
/* The symbols being reduced. */ /* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++) for (yyi = 0; yyi < yynrhs; yyi++)
{ {
YYFPRINTF (stderr, " $%d = ", yyi + 1); YY_FPRINTF ((stderr, " $%d = ", yyi + 1));
yy_symbol_print (stderr, yy_symbol_print (stderr,
yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState], yystos[yyvsp[yyi - yynrhs + 1].yystate.yylrState],
&yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval]b4_locations_if([, &yyvsp[yyi - yynrhs + 1].yystate.yysemantics.yysval]b4_locations_if([,
&]b4_rhs_location(yynrhs, yyi + 1))[]dnl &]b4_rhs_location(yynrhs, yyi + 1))[]dnl
b4_user_args[); b4_user_args[);
if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved) if (!yyvsp[yyi - yynrhs + 1].yystate.yyresolved)
YYFPRINTF (stderr, " (unresolved)"); YY_FPRINTF ((stderr, " (unresolved)"));
YYFPRINTF (stderr, "\n"); YY_FPRINTF ((stderr, "\n"));
} }
} }
#endif #endif
@@ -1447,9 +1460,9 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[); YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR) if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR)
YYDPRINTF ((stderr, YY_DPRINTF ((stderr,
"Parse on stack %ld rejected by rule %d (line %d).\n", "Parse on stack %ld rejected by rule %d (line %d).\n",
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule - 1])); YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule - 1]));
if (yyflag != yyok) if (yyflag != yyok)
return yyflag; return yyflag;
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc); YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyrule], &yysval, &yyloc);
@@ -1473,11 +1486,11 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
} }
yyupdateSplit (yystackp, yys); yyupdateSplit (yystackp, yys);
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule)); yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
YYDPRINTF ((stderr, YY_DPRINTF ((stderr,
"Reduced stack %ld by rule %d (line %d); action deferred. " "Reduced stack %ld by rule %d (line %d); action deferred. "
"Now in state %d.\n", "Now in state %d.\n",
YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule - 1], YY_CAST (long, yyk), yyrule - 1, yyrline[yyrule - 1],
yynewLRState)); yynewLRState));
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR) if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR)
{ {
@@ -1489,8 +1502,8 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
{ {
yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule); yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
yymarkStackDeleted (yystackp, yyk); yymarkStackDeleted (yystackp, yyk);
YYDPRINTF ((stderr, "Merging stack %ld into stack %ld.\n", YY_DPRINTF ((stderr, "Merging stack %ld into stack %ld.\n",
YY_CAST (long, yyk), YY_CAST (long, yyi))); YY_CAST (long, yyk), YY_CAST (long, yyi)));
return yyok; return yyok;
} }
yyp = yyp->yypred; yyp = yyp->yypred;
@@ -1732,26 +1745,26 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
yystates[0] = yys; yystates[0] = yys;
if (yyx->yystate->yyposn < yys->yyposn + 1) if (yyx->yystate->yyposn < yys->yyposn + 1)
YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n", YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, empty>\n",
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1); yyx->yyrule - 1));
else else
YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n", YY_FPRINTF ((stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)), yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
yyx->yyrule - 1, YY_CAST (long, yys->yyposn + 1), yyx->yyrule - 1, YY_CAST (long, yys->yyposn + 1),
YY_CAST (long, yyx->yystate->yyposn)); YY_CAST (long, yyx->yystate->yyposn)));
for (yyi = 1; yyi <= yynrhs; yyi += 1) for (yyi = 1; yyi <= yynrhs; yyi += 1)
{ {
if (yystates[yyi]->yyresolved) if (yystates[yyi]->yyresolved)
{ {
if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn) if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "", YY_FPRINTF ((stderr, "%*s%s <empty>\n", yyindent+2, "",
yytokenName (yystos[yystates[yyi]->yylrState])); yytokenName (yystos[yystates[yyi]->yylrState])));
else else
YYFPRINTF (stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "", YY_FPRINTF ((stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "",
yytokenName (yystos[yystates[yyi]->yylrState]), yytokenName (yystos[yystates[yyi]->yylrState]),
YY_CAST (long, yystates[yyi-1]->yyposn + 1), YY_CAST (long, yystates[yyi-1]->yyposn + 1),
YY_CAST (long, yystates[yyi]->yyposn)); YY_CAST (long, yystates[yyi]->yyposn)));
} }
else else
yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2); yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
@@ -1767,12 +1780,12 @@ yyreportAmbiguity (yySemanticOption* yyx0,
YYUSE (yyx1); YYUSE (yyx1);
#if ]b4_api_PREFIX[DEBUG #if ]b4_api_PREFIX[DEBUG
YYFPRINTF (stderr, "Ambiguity detected.\n"); YY_FPRINTF ((stderr, "Ambiguity detected.\n"));
YYFPRINTF (stderr, "Option 1,\n"); YY_FPRINTF ((stderr, "Option 1,\n"));
yyreportTree (yyx0, 2); yyreportTree (yyx0, 2);
YYFPRINTF (stderr, "\nOption 2,\n"); YY_FPRINTF ((stderr, "\nOption 2,\n"));
yyreportTree (yyx1, 2); yyreportTree (yyx1, 2);
YYFPRINTF (stderr, "\n"); YY_FPRINTF ((stderr, "\n"));
#endif #endif
yyerror (]b4_yyerror_args[YY_("syntax is ambiguous")); yyerror (]b4_yyerror_args[YY_("syntax is ambiguous"));
@@ -1970,7 +1983,7 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
while (yystackp->yytops.yystates[yyk] != YY_NULLPTR) while (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
{ {
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState; yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
YYDPRINTF ((stderr, "Stack %ld Entering state %d\n", yyk, yystate)); YY_DPRINTF ((stderr, "Stack %ld Entering state %d\n", yyk, yystate));
YYASSERT (yystate != YYFINAL); YYASSERT (yystate != YYFINAL);
@@ -1980,17 +1993,17 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
yyRuleNum yyrule = yydefaultAction (yystate); yyRuleNum yyrule = yydefaultAction (yystate);
if (yyrule == 0) if (yyrule == 0)
{ {
YYDPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk))); YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk)));
yymarkStackDeleted (yystackp, yyk); yymarkStackDeleted (yystackp, yyk);
return yyok; return yyok;
} }
yyflag = yyglrReduce (yystackp, yyk, yyrule, yyimmediate[yyrule]]b4_user_args[); yyflag = yyglrReduce (yystackp, yyk, yyrule, yyimmediate[yyrule]]b4_user_args[);
if (yyflag == yyerr) if (yyflag == yyerr)
{ {
YYDPRINTF ((stderr, YY_DPRINTF ((stderr,
"Stack %ld dies " "Stack %ld dies "
"(predicate failure or explicit user error).\n", "(predicate failure or explicit user error).\n",
YY_CAST (long, yyk))); YY_CAST (long, yyk)));
yymarkStackDeleted (yystackp, yyk); yymarkStackDeleted (yystackp, yyk);
return yyok; return yyok;
} }
@@ -2008,8 +2021,8 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
{ {
YYRESULTTAG yyflag; YYRESULTTAG yyflag;
ptrdiff_t yynewStack = yysplitStack (yystackp, yyk); ptrdiff_t yynewStack = yysplitStack (yystackp, yyk);
YYDPRINTF ((stderr, "Splitting off stack %ld from %ld.\n", YY_DPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
YY_CAST (long, yynewStack), YY_CAST (long, yyk))); YY_CAST (long, yynewStack), YY_CAST (long, yyk)));
yyflag = yyglrReduce (yystackp, yynewStack, yyflag = yyglrReduce (yystackp, yynewStack,
*yyconflicts, *yyconflicts,
yyimmediate[*yyconflicts]]b4_user_args[); yyimmediate[*yyconflicts]]b4_user_args[);
@@ -2018,7 +2031,7 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
yyposn]b4_pure_args[)); yyposn]b4_pure_args[));
else if (yyflag == yyerr) else if (yyflag == yyerr)
{ {
YYDPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yynewStack))); YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yynewStack)));
yymarkStackDeleted (yystackp, yynewStack); yymarkStackDeleted (yystackp, yynewStack);
} }
else else
@@ -2030,7 +2043,7 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
break; break;
else if (yyisErrorAction (yyaction)) else if (yyisErrorAction (yyaction))
{ {
YYDPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk))); YY_DPRINTF ((stderr, "Stack %ld dies.\n", YY_CAST (long, yyk)));
yymarkStackDeleted (yystackp, yyk); yymarkStackDeleted (yystackp, yyk);
break; break;
} }
@@ -2040,10 +2053,10 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
yyimmediate[-yyaction]]b4_user_args[); yyimmediate[-yyaction]]b4_user_args[);
if (yyflag == yyerr) if (yyflag == yyerr)
{ {
YYDPRINTF ((stderr, YY_DPRINTF ((stderr,
"Stack %ld dies " "Stack %ld dies "
"(predicate failure or explicit user error).\n", "(predicate failure or explicit user error).\n",
YY_CAST (long, yyk))); YY_CAST (long, yyk)));
yymarkStackDeleted (yystackp, yyk); yymarkStackDeleted (yystackp, yyk);
break; break;
} }
@@ -2319,7 +2332,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yyGLRStack* const yystackp = &yystack; yyGLRStack* const yystackp = &yystack;
ptrdiff_t yyposn; ptrdiff_t yyposn;
YYDPRINTF ((stderr, "Starting parse\n")); YY_DPRINTF ((stderr, "Starting parse\n"));
yychar = YYEMPTY; yychar = YYEMPTY;
yylval = yyval_default;]b4_locations_if([ yylval = yyval_default;]b4_locations_if([
@@ -2350,7 +2363,7 @@ b4_dollar_popdef])[]dnl
while (yytrue) while (yytrue)
{ {
yyStateNum yystate = yystack.yytops.yystates[0]->yylrState; yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
YYDPRINTF ((stderr, "Entering state %d\n", yystate)); YY_DPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL) if (yystate == YYFINAL)
goto yyacceptlab; goto yyacceptlab;
if (yyisDefaultedState (yystate)) if (yyisDefaultedState (yystate))
@@ -2430,7 +2443,7 @@ b4_dollar_popdef])[]dnl
if (yystack.yytops.yysize == 0) if (yystack.yytops.yysize == 0)
yyFail (&yystack][]b4_lpure_args[, YY_("syntax error")); yyFail (&yystack][]b4_lpure_args[, YY_("syntax error"));
YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));]b4_locations_if([[ YY_DPRINTF ((stderr, "Returning to deterministic operation.\n"));]b4_locations_if([[
yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[ yystack.yyerror_range[1].yystate.yyloc = yylloc;]])[
yyreportSyntaxError (&yystack]b4_user_args[); yyreportSyntaxError (&yystack]b4_user_args[);
goto yyuser_error; goto yyuser_error;
@@ -2451,19 +2464,19 @@ b4_dollar_popdef])[]dnl
int yyaction = yygetLRActions (yystate, yytoken_to_shift, int yyaction = yygetLRActions (yystate, yytoken_to_shift,
&yyconflicts); &yyconflicts);
/* Note that yyconflicts were handled by yyprocessOneStack. */ /* Note that yyconflicts were handled by yyprocessOneStack. */
YYDPRINTF ((stderr, "On stack %ld, ", YY_CAST (long, yys))); YY_DPRINTF ((stderr, "On stack %ld, ", YY_CAST (long, yys)));
YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc); YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
yyglrShift (&yystack, yys, yyaction, yyposn, yyglrShift (&yystack, yys, yyaction, yyposn,
&yylval]b4_locations_if([, &yylloc])[); &yylval]b4_locations_if([, &yylloc])[);
YYDPRINTF ((stderr, "Stack %ld now in state #%d\n", YY_DPRINTF ((stderr, "Stack %ld now in state #%d\n",
YY_CAST (long, yys), YY_CAST (long, yys),
yystack.yytops.yystates[yys]->yylrState)); yystack.yytops.yystates[yys]->yylrState));
} }
if (yystack.yytops.yysize == 1) if (yystack.yytops.yysize == 1)
{ {
YYCHK1 (yyresolveStack (&yystack]b4_user_args[)); YYCHK1 (yyresolveStack (&yystack]b4_user_args[));
YYDPRINTF ((stderr, "Returning to deterministic operation.\n")); YY_DPRINTF ((stderr, "Returning to deterministic operation.\n"));
yycompressStack (&yystack); yycompressStack (&yystack);
break; break;
} }
@@ -2536,19 +2549,19 @@ yy_yypstack (yyGLRState* yys)
if (yys->yypred) if (yys->yypred)
{ {
yy_yypstack (yys->yypred); yy_yypstack (yys->yypred);
YYFPRINTF (stderr, " -> "); YY_FPRINTF ((stderr, " -> "));
} }
YYFPRINTF (stderr, "%d@@%ld", yys->yylrState, YY_CAST (long, yys->yyposn)); YY_FPRINTF ((stderr, "%d@@%ld", yys->yylrState, YY_CAST (long, yys->yyposn)));
} }
static void static void
yypstates (yyGLRState* yyst) yypstates (yyGLRState* yyst)
{ {
if (yyst == YY_NULLPTR) if (yyst == YY_NULLPTR)
YYFPRINTF (stderr, "<null>"); YY_FPRINTF ((stderr, "<null>"));
else else
yy_yypstack (yyst); yy_yypstack (yyst);
YYFPRINTF (stderr, "\n"); YY_FPRINTF ((stderr, "\n"));
} }
static void static void
@@ -2569,39 +2582,39 @@ yypdumpstack (yyGLRStack* yystackp)
yyGLRStackItem* yyp; yyGLRStackItem* yyp;
for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1) for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
{ {
YYFPRINTF (stderr, "%3ld. ", YY_FPRINTF ((stderr, "%3ld. ",
YY_CAST (long, yyp - yystackp->yyitems)); YY_CAST (long, yyp - yystackp->yyitems)));
if (*YY_REINTERPRET_CAST (yybool *, yyp)) if (*YY_REINTERPRET_CAST (yybool *, yyp))
{ {
YYASSERT (yyp->yystate.yyisState); YYASSERT (yyp->yystate.yyisState);
YYASSERT (yyp->yyoption.yyisState); YYASSERT (yyp->yyoption.yyisState);
YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %ld, pred: %ld", YY_FPRINTF ((stderr, "Res: %d, LR State: %d, posn: %ld, pred: %ld",
yyp->yystate.yyresolved, yyp->yystate.yylrState, yyp->yystate.yyresolved, yyp->yystate.yylrState,
YY_CAST (long, yyp->yystate.yyposn), YY_CAST (long, yyp->yystate.yyposn),
YYINDEX (yyp->yystate.yypred)); YYINDEX (yyp->yystate.yypred)));
if (! yyp->yystate.yyresolved) if (! yyp->yystate.yyresolved)
YYFPRINTF (stderr, ", firstVal: %ld", YY_FPRINTF ((stderr, ", firstVal: %ld",
YYINDEX (yyp->yystate.yysemantics.yyfirstVal)); YYINDEX (yyp->yystate.yysemantics.yyfirstVal)));
} }
else else
{ {
YYASSERT (!yyp->yystate.yyisState); YYASSERT (!yyp->yystate.yyisState);
YYASSERT (!yyp->yyoption.yyisState); YYASSERT (!yyp->yyoption.yyisState);
YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld", YY_FPRINTF ((stderr, "Option. rule: %d, state: %ld, next: %ld",
yyp->yyoption.yyrule - 1, yyp->yyoption.yyrule - 1,
YYINDEX (yyp->yyoption.yystate), YYINDEX (yyp->yyoption.yystate),
YYINDEX (yyp->yyoption.yynext)); YYINDEX (yyp->yyoption.yynext)));
} }
YYFPRINTF (stderr, "\n"); YY_FPRINTF ((stderr, "\n"));
} }
YYFPRINTF (stderr, "Tops:"); YY_FPRINTF ((stderr, "Tops:"));
{ {
ptrdiff_t yyi; ptrdiff_t yyi;
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
YYFPRINTF (stderr, "%ld: %ld; ", YY_CAST (long, yyi), YY_FPRINTF ((stderr, "%ld: %ld; ", YY_CAST (long, yyi),
YYINDEX (yystackp->yytops.yystates[yyi])); YYINDEX (yystackp->yytops.yystates[yyi])));
YYFPRINTF (stderr, "\n"); YY_FPRINTF ((stderr, "\n"));
} }
#undef YYINDEX #undef YYINDEX
} }

View File

@@ -854,8 +854,10 @@ yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
*yybottom = yybottom_new; *yybottom = yybottom_new;
*yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]), *yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
[full], [[ [full], [[
YY_IGNORE_USELESS_CAST_BEGIN
YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix, YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix,
YY_CAST (long, yyalloc), yydebug_suffix));]])[ YY_CAST (long, yyalloc), yydebug_suffix));
YY_IGNORE_USELESS_CAST_END]])[
} }
return 0; return 0;
} }
@@ -1012,7 +1014,9 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
if (yyesp == yyes_prev) if (yyesp == yyes_prev)
{ {
yyesp = *yyes; yyesp = *yyes;
YY_IGNORE_USELESS_CAST_BEGIN
*yyesp = YY_CAST (yy_state_t, yystate); *yyesp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
} }
else else
{ {
@@ -1025,7 +1029,9 @@ yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
YYDPRINTF ((stderr, "\n")); YYDPRINTF ((stderr, "\n"));
return 2; return 2;
} }
YY_IGNORE_USELESS_CAST_BEGIN
*++yyesp = YY_CAST (yy_state_t, yystate); *++yyesp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
} }
YYDPRINTF ((stderr, " G%d", yystate)); YYDPRINTF ((stderr, " G%d", yystate));
} }
@@ -1492,7 +1498,9 @@ yynewstate:
yysetstate: yysetstate:
YYDPRINTF ((stderr, "Entering state %d\n", yystate)); YYDPRINTF ((stderr, "Entering state %d\n", yystate));
YY_ASSERT (0 <= yystate && yystate < YYNSTATES); YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
*yyssp = YY_CAST (yy_state_t, yystate); YY_IGNORE_USELESS_CAST_BEGIN
*yyssp = YY_CAST (yy_state_t, yystate);
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp) if (yyss + yystacksize - 1 <= yyssp)
#if !defined yyoverflow && !defined YYSTACK_RELOCATE #if !defined yyoverflow && !defined YYSTACK_RELOCATE
@@ -1552,8 +1560,10 @@ yysetstate:
yyvsp = yyvs + yysize - 1;]b4_locations_if([ yyvsp = yyvs + yysize - 1;]b4_locations_if([
yylsp = yyls + yysize - 1;])[ yylsp = yyls + yysize - 1;])[
YY_IGNORE_USELESS_CAST_BEGIN
YYDPRINTF ((stderr, "Stack size increased to %ld\n", YYDPRINTF ((stderr, "Stack size increased to %ld\n",
YY_CAST (long, yystacksize))); YY_CAST (long, yystacksize)));
YY_IGNORE_USELESS_CAST_END
if (yyss + yystacksize - 1 <= yyssp) if (yyss + yystacksize - 1 <= yyssp)
YYABORT; YYABORT;

View File

@@ -1780,7 +1780,7 @@ float: UNTYPED INT
yy::parser::token::INT, yy::parser::token::INT,
EOF}]], EOF}]],
[[{UNTYPED, INT, EOF}]]), [[{UNTYPED, INT, EOF}]]),
[AT_VAL.ival = YY_CAST (int, toknum) * 10; [AT_VAL.ival = toknum * 10;
AT_VAL.fval = YY_CAST (float, toknum) / 10.0f;])[ AT_VAL.fval = YY_CAST (float, toknum) / 10.0f;])[
]AT_MAIN_DEFINE[ ]AT_MAIN_DEFINE[
]]) ]])
@@ -1897,7 +1897,7 @@ exp:
%% %%
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[
]AT_YYLEX_DEFINE(["bcd"], [*lvalp = YY_CAST (int, (toknum + 1) * 10)])[ ]AT_YYLEX_DEFINE(["bcd"], [*lvalp = (toknum + 1) * 10])[
]AT_MAIN_DEFINE[ ]AT_MAIN_DEFINE[
]]) ]])
AT_BISON_OPTION_POPDEFS AT_BISON_OPTION_POPDEFS

View File

@@ -326,7 +326,7 @@ AT_PERL_CHECK([[-n -0777 -e '
|YY_CONSTEXPR |YY_CONSTEXPR
|YY_COPY |YY_COPY
|YY_CPLUSPLUS |YY_CPLUSPLUS
|YY_IGNORE_MAYBE_UNINITIALIZED_(?:BEGIN|END) |YY_IGNORE_(?:MAYBE_UNINITIALIZED|USELESS_CAST)_(?:BEGIN|END)
|YY_INITIAL_VALUE |YY_INITIAL_VALUE
|YY_MOVE |YY_MOVE
|YY_MOVE_OR_COPY |YY_MOVE_OR_COPY