mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Cleanups so that Bison-generated parsers have less lint.
* data/c.m4 (b4_yydestruct_generate, b4_yysymprint_generate): Prepend /*ARGSUSED*/, for lint's sake. * data/glr.c (YYUSE): Properly parenthesize, and use an alternate definition if 'lint' is defined. (YYID): New macro (or function, if lint). All uses of /*CONSTCOND*/0 replaced by YYID(0). * data/yacc.c: Likewise. * data/glr.c (yyuserAction, yyuserMerge, yy_reduce_print): (yyrecoverSyntaxError): Prepend /*ARGSUSED*/. * data/glr.cc (YYLLOC_DEFAULT): Omit /*CONSTCOND*/ since this code is C++ only. * data/lalr1.cc (YYUSE): Just use a cast, since this code is C++ only. * data/yacc.c (YYSTACK_FREE) [defined YYSTACK_ALLOC]: Use YYID(0) rather than 0, for lint. (yystrlen): Rewrite to avoid lint warning about ptrdiff_t overflow. (yysyntax_error): Rewrite to avoid lint warnings about parenthesization.
This commit is contained in:
@@ -401,6 +401,7 @@ m4_define_default([b4_yydestruct_generate],
|
|||||||
| Release the memory associated to this symbol. |
|
| Release the memory associated to this symbol. |
|
||||||
`-----------------------------------------------*/
|
`-----------------------------------------------*/
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
]$1([yydestruct],
|
]$1([yydestruct],
|
||||||
[static void],
|
[static void],
|
||||||
[[const char *yymsg], [yymsg]],
|
[[const char *yymsg], [yymsg]],
|
||||||
@@ -438,6 +439,7 @@ m4_define_default([b4_yysymprint_generate],
|
|||||||
| Print this symbol on YYOUTPUT. |
|
| Print this symbol on YYOUTPUT. |
|
||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
|
||||||
|
/*ARGSUSED*/
|
||||||
]$1([yysymprint],
|
]$1([yysymprint],
|
||||||
[static void],
|
[static void],
|
||||||
[[FILE *yyoutput], [yyoutput]],
|
[[FILE *yyoutput], [yyoutput]],
|
||||||
|
|||||||
40
data/glr.c
40
data/glr.c
@@ -257,10 +257,20 @@ b4_syncline([@oline@], [@ofile@])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Suppress unused-variable warnings by "using" E. */
|
/* Suppress unused-variable warnings by "using" E. */
|
||||||
#if __cplusplus
|
#ifndef lint
|
||||||
# define YYUSE(e) (void) (e)
|
# define YYUSE(e) ((void) (e))
|
||||||
#else
|
#else
|
||||||
# define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e))
|
# define YYUSE(e) /* empty */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Identity function, used to suppress warnings about constant conditions. */
|
||||||
|
#ifndef lint
|
||||||
|
# define YYID(n) (n)
|
||||||
|
#else
|
||||||
|
]b4_c_function_def([YYID], [static int], [[int i], [i]])[
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef YYFREE
|
#ifndef YYFREE
|
||||||
@@ -499,7 +509,7 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] =
|
|||||||
(Current).first_column = (Current).last_column = \
|
(Current).first_column = (Current).last_column = \
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
YYRHSLOC (Rhs, 0).last_column; \
|
||||||
} \
|
} \
|
||||||
while (/*CONSTCOND*/ 0)
|
while (YYID (0))
|
||||||
|
|
||||||
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
/* YY_LOCATION_PRINT -- Print the location on the stream.
|
||||||
This macro was not mandated originally: define only if we know
|
This macro was not mandated originally: define only if we know
|
||||||
@@ -544,7 +554,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
|||||||
|
|
||||||
#define YYCHK(YYE) \
|
#define YYCHK(YYE) \
|
||||||
do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
|
do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
|
||||||
while (/*CONSTCOND*/ 0)
|
while (YYID (0))
|
||||||
|
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
|
|
||||||
@@ -556,7 +566,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
|||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
YYFPRINTF Args; \
|
YYFPRINTF Args; \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
|
|
||||||
]b4_yysymprint_generate([b4_c_ansi_function_def])[
|
]b4_yysymprint_generate([b4_c_ansi_function_def])[
|
||||||
|
|
||||||
@@ -569,7 +579,7 @@ do { \
|
|||||||
Type, Value]b4_location_if([, Location])[]b4_user_args[); \
|
Type, Value]b4_location_if([, Location])[]b4_user_args[); \
|
||||||
YYFPRINTF (stderr, "\n"); \
|
YYFPRINTF (stderr, "\n"); \
|
||||||
} \
|
} \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
|
|
||||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||||
multiple parsers can coexist. */
|
multiple parsers can coexist. */
|
||||||
@@ -620,13 +630,13 @@ int yydebug;
|
|||||||
do { \
|
do { \
|
||||||
if (Yystack->yyspaceLeft < YYHEADROOM) \
|
if (Yystack->yyspaceLeft < YYHEADROOM) \
|
||||||
yyexpandGLRStack (Yystack); \
|
yyexpandGLRStack (Yystack); \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
#else
|
#else
|
||||||
# define YY_RESERVE_GLRSTACK(Yystack) \
|
# define YY_RESERVE_GLRSTACK(Yystack) \
|
||||||
do { \
|
do { \
|
||||||
if (Yystack->yyspaceLeft < YYHEADROOM) \
|
if (Yystack->yyspaceLeft < YYHEADROOM) \
|
||||||
yyMemoryExhausted (Yystack); \
|
yyMemoryExhausted (Yystack); \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -862,7 +872,7 @@ yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
|
|||||||
* value ($$), and yylocp points to place for location information
|
* value ($$), and yylocp points to place for location information
|
||||||
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
|
* (@@$). Returns yyok for normal return, yyaccept for YYACCEPT,
|
||||||
* yyerr for YYERROR, yyabort for YYABORT. */
|
* yyerr for YYERROR, yyabort for YYABORT. */
|
||||||
static YYRESULTTAG
|
/*ARGSUSED*/ static YYRESULTTAG
|
||||||
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
|
||||||
YYSTYPE* yyvalp,
|
YYSTYPE* yyvalp,
|
||||||
YYLTYPE* YYOPTIONAL_LOC (yylocp),
|
YYLTYPE* YYOPTIONAL_LOC (yylocp),
|
||||||
@@ -919,7 +929,7 @@ b4_syncline([@oline@], [@ofile@])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
/*ARGSUSED*/ static void
|
||||||
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
|
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
|
||||||
{
|
{
|
||||||
YYUSE (yy0);
|
YYUSE (yy0);
|
||||||
@@ -1360,13 +1370,13 @@ yydoAction (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
|
|||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_reduce_print Args; \
|
yy_reduce_print Args; \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
|
|
||||||
/*----------------------------------------------------------.
|
/*----------------------------------------------------------.
|
||||||
| Report that the RULE is going to be reduced on stack #K. |
|
| Report that the RULE is going to be reduced on stack #K. |
|
||||||
`----------------------------------------------------------*/
|
`----------------------------------------------------------*/
|
||||||
|
|
||||||
static inline void
|
/*ARGSUSED*/ static inline void
|
||||||
yy_reduce_print (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
|
yy_reduce_print (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
|
||||||
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
YYSTYPE* yyvalp, YYLTYPE* yylocp]b4_user_formals[)
|
||||||
{
|
{
|
||||||
@@ -2003,7 +2013,7 @@ yyreportSyntaxError (yyGLRStack* yystack,
|
|||||||
/* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
|
/* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
|
||||||
YYLVALP, and YYLLOCP point to the syntactic category, semantic
|
YYLVALP, and YYLLOCP point to the syntactic category, semantic
|
||||||
value, and location of the look-ahead. */
|
value, and location of the look-ahead. */
|
||||||
static void
|
/*ARGSUSED*/ static void
|
||||||
yyrecoverSyntaxError (yyGLRStack* yystack,
|
yyrecoverSyntaxError (yyGLRStack* yystack,
|
||||||
YYSTYPE* yylvalp,
|
YYSTYPE* yylvalp,
|
||||||
YYLTYPE* YYOPTIONAL_LOC (yyllocp)
|
YYLTYPE* YYOPTIONAL_LOC (yyllocp)
|
||||||
@@ -2108,7 +2118,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
default: \
|
default: \
|
||||||
goto yybuglab; \
|
goto yybuglab; \
|
||||||
} \
|
} \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
/*----------.
|
/*----------.
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
{ \
|
{ \
|
||||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
||||||
} \
|
} \
|
||||||
while (/*CONSTCOND*/ 0)
|
while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace yy
|
namespace yy
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Suppress unused-variable warnings by "using" E. */
|
/* Suppress unused-variable warnings by "using" E. */
|
||||||
#define YYUSE(e) do {;} while (false && (e))
|
#define YYUSE(e) ((void) (e))
|
||||||
|
|
||||||
/* A pseudo ostream that takes yydebug_ into account. */
|
/* A pseudo ostream that takes yydebug_ into account. */
|
||||||
# define YYCDEBUG \
|
# define YYCDEBUG \
|
||||||
|
|||||||
48
data/yacc.c
48
data/yacc.c
@@ -261,7 +261,21 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Suppress unused-variable warnings by "using" E. */
|
/* Suppress unused-variable warnings by "using" E. */
|
||||||
#define YYUSE(e) do {;} while (/*CONSTCOND*/ 0 && (e))
|
#ifndef lint
|
||||||
|
# define YYUSE(e) ((void) (e))
|
||||||
|
#else
|
||||||
|
# define YYUSE(e) /* empty */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Identity function, used to suppress warnings about constant conditions. */
|
||||||
|
#ifndef lint
|
||||||
|
# define YYID(n) (n)
|
||||||
|
#else
|
||||||
|
]b4_c_function_def([YYID], [static int], [[int i], [i]])[
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ! defined (yyoverflow) || YYERROR_VERBOSE
|
#if ! defined (yyoverflow) || YYERROR_VERBOSE
|
||||||
|
|
||||||
@@ -292,7 +306,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
|
|
||||||
# ifdef YYSTACK_ALLOC
|
# ifdef YYSTACK_ALLOC
|
||||||
/* Pacify GCC's `empty if-body' warning. */
|
/* Pacify GCC's `empty if-body' warning. */
|
||||||
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
|
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
|
||||||
# ifndef YYSTACK_ALLOC_MAXIMUM
|
# ifndef YYSTACK_ALLOC_MAXIMUM
|
||||||
/* The OS might guarantee only one guard page at the bottom of the stack,
|
/* The OS might guarantee only one guard page at the bottom of the stack,
|
||||||
and a page size can be as small as 4096 bytes. So we cannot safely
|
and a page size can be as small as 4096 bytes. So we cannot safely
|
||||||
@@ -369,7 +383,7 @@ union yyalloc
|
|||||||
for (yyi = 0; yyi < (Count); yyi++) \
|
for (yyi = 0; yyi < (Count); yyi++) \
|
||||||
(To)[yyi] = (From)[yyi]; \
|
(To)[yyi] = (From)[yyi]; \
|
||||||
} \
|
} \
|
||||||
while (/*CONSTCOND*/ 0)
|
while (YYID (0))
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -387,7 +401,7 @@ union yyalloc
|
|||||||
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||||
yyptr += yynewbytes / sizeof (*yyptr); \
|
yyptr += yynewbytes / sizeof (*yyptr); \
|
||||||
} \
|
} \
|
||||||
while (/*CONSTCOND*/ 0)
|
while (YYID (0))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -558,7 +572,7 @@ do \
|
|||||||
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
|
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
|
||||||
YYERROR; \
|
YYERROR; \
|
||||||
} \
|
} \
|
||||||
while (/*CONSTCOND*/ 0)
|
while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
#define YYTERROR 1
|
#define YYTERROR 1
|
||||||
@@ -587,7 +601,7 @@ while (/*CONSTCOND*/ 0)
|
|||||||
(Current).first_column = (Current).last_column = \
|
(Current).first_column = (Current).last_column = \
|
||||||
YYRHSLOC (Rhs, 0).last_column; \
|
YYRHSLOC (Rhs, 0).last_column; \
|
||||||
} \
|
} \
|
||||||
while (/*CONSTCOND*/ 0)
|
while (YYID (0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -627,7 +641,7 @@ while (/*CONSTCOND*/ 0)
|
|||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
YYFPRINTF Args; \
|
YYFPRINTF Args; \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
|
|
||||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
do { \
|
do { \
|
||||||
@@ -638,7 +652,7 @@ do { \
|
|||||||
Type, Value]b4_location_if([, Location])[]b4_user_args[); \
|
Type, Value]b4_location_if([, Location])[]b4_user_args[); \
|
||||||
YYFPRINTF (stderr, "\n"); \
|
YYFPRINTF (stderr, "\n"); \
|
||||||
} \
|
} \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
|
|
||||||
]b4_yysymprint_generate([b4_c_function_def])[
|
]b4_yysymprint_generate([b4_c_function_def])[
|
||||||
|
|
||||||
@@ -661,7 +675,7 @@ do { \
|
|||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_stack_print ((Bottom), (Top)); \
|
yy_stack_print ((Bottom), (Top)); \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------.
|
/*------------------------------------------------.
|
||||||
@@ -695,7 +709,7 @@ do { \
|
|||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
yy_reduce_print (yyvsp, ]b4_location_if([yylsp, ])[Rule]b4_user_args[); \
|
yy_reduce_print (yyvsp, ]b4_location_if([yylsp, ])[Rule]b4_user_args[); \
|
||||||
} while (/*CONSTCOND*/ 0)
|
} while (YYID (0))
|
||||||
|
|
||||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||||
multiple parsers can coexist. */
|
multiple parsers can coexist. */
|
||||||
@@ -741,12 +755,10 @@ yystrlen (yystr)
|
|||||||
const char *yystr;
|
const char *yystr;
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
const char *yys = yystr;
|
YYSIZE_T yylen;
|
||||||
|
for (yylen = 0; yystr[yylen]; yylen++)
|
||||||
while (*yys++ != '\0')
|
|
||||||
continue;
|
continue;
|
||||||
|
return yylen;
|
||||||
return yys - yystr - 1;
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
@@ -894,7 +906,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
|||||||
}
|
}
|
||||||
yyarg[yycount++] = yytname[yyx];
|
yyarg[yycount++] = yytname[yyx];
|
||||||
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
|
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
|
||||||
yysize_overflow |= yysize1 < yysize;
|
yysize_overflow |= (yysize1 < yysize);
|
||||||
yysize = yysize1;
|
yysize = yysize1;
|
||||||
yyfmt = yystpcpy (yyfmt, yyprefix);
|
yyfmt = yystpcpy (yyfmt, yyprefix);
|
||||||
yyprefix = yyor;
|
yyprefix = yyor;
|
||||||
@@ -902,7 +914,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
|||||||
|
|
||||||
yyf = YY_(yyformat);
|
yyf = YY_(yyformat);
|
||||||
yysize1 = yysize + yystrlen (yyf);
|
yysize1 = yysize + yystrlen (yyf);
|
||||||
yysize_overflow |= yysize1 < yysize;
|
yysize_overflow |= (yysize1 < yysize);
|
||||||
yysize = yysize1;
|
yysize = yysize1;
|
||||||
|
|
||||||
if (yysize_overflow)
|
if (yysize_overflow)
|
||||||
@@ -915,7 +927,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
|||||||
produced a string with the wrong number of "%s"s. */
|
produced a string with the wrong number of "%s"s. */
|
||||||
char *yyp = yyresult;
|
char *yyp = yyresult;
|
||||||
int yyi = 0;
|
int yyi = 0;
|
||||||
while ((*yyp = *yyf))
|
while ((*yyp = *yyf) != '\0')
|
||||||
{
|
{
|
||||||
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
|
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user