From 2a4647a32f3de7eda80133370b05cea9f72e5761 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 6 Oct 2005 07:17:21 +0000 Subject: [PATCH] * data/c.m4 (yydestruct, yysymprint): Use YYUSE instead of casting to void. * data/glr.c (YYUSE): New macro. (yyuserMerge, yyreportAmbiguity, yyreportSyntaxError): Use it instead of rolling our own. (YYLLOC_DEFAULT, YYCHK, YYDPRINTF, YY_SYMBOL_PRINT, YY_REDUCE_PRINT): (YYCHK1): Use /*CONSTCOND*/ to suppress lint warnings. * data/lalr1.cc (YYLLOC_DEFAULT, YY_SYMBOL_PRINT, YY_REDUCE_PRINT): (YY_STACK_PRINT): Use 'false' not '0'. (YYUSE): New macro. (yysymprint_, yydestruct_): Use it instead of rolling our own. * data/yacc.c (YYUSE): New macro. (YYCOPY, YYSTACK_RELOCATE, YYBACKUP, YYLLOC_DEFAULT): (YYDPRINTF, YY_SYMBOL_PRINT, YY_STACK_PRINT, YY_REDUCE_PRINT): (yyerrorlab): Use /*CONSTCOND*/ to suppress lint warnings. --- ChangeLog | 18 ++++++++++++++++++ data/c.m4 | 10 ++++------ data/glr.c | 30 +++++++++++++++--------------- data/lalr1.cc | 23 +++++++++++++---------- data/yacc.c | 21 ++++++++++++--------- 5 files changed, 62 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7dd3668..f658dca5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ 2005-10-05 Paul Eggert + * data/c.m4 (yydestruct, yysymprint): + Use YYUSE instead of casting to void. + * data/glr.c (YYUSE): New macro. + (yyuserMerge, yyreportAmbiguity, yyreportSyntaxError): + Use it instead of rolling our own. + (YYLLOC_DEFAULT, YYCHK, YYDPRINTF, YY_SYMBOL_PRINT, YY_REDUCE_PRINT): + (YYCHK1): + Use /*CONSTCOND*/ to suppress lint warnings. + * data/lalr1.cc (YYLLOC_DEFAULT, YY_SYMBOL_PRINT, YY_REDUCE_PRINT): + (YY_STACK_PRINT): Use 'false' not '0'. + (YYUSE): New macro. + (yysymprint_, yydestruct_): Use it instead of rolling our own. + * data/yacc.c (YYUSE): New macro. + (YYCOPY, YYSTACK_RELOCATE, YYBACKUP, YYLLOC_DEFAULT): + (YYDPRINTF, YY_SYMBOL_PRINT, YY_STACK_PRINT, YY_REDUCE_PRINT): + (yyerrorlab): Use /*CONSTCOND*/ to suppress lint warnings. + + * data/m4sugar/m4sugar.m4 (_m4_map): New macro. (m4_map, m4_map_sep): Use it. Handle the empty list correctly. diff --git a/data/c.m4 b/data/c.m4 index 03f20ff7..604ad138 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -385,9 +385,8 @@ m4_define_default([b4_yydestruct_generate], [[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([, [[YYLTYPE *yylocationp], [yylocationp]]]))[ { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; -]b4_location_if([ (void) yylocationp; + YYUSE (yyvaluep); +]b4_location_if([ YYUSE (yylocationp); ])[ if (!yymsg) yymsg = "Deleting"; @@ -420,9 +419,8 @@ m4_define_default([b4_yysymprint_generate], [[YYSTYPE *yyvaluep], [yyvaluep]]b4_location_if([, [[YYLTYPE *yylocationp], [yylocationp]]])) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; -b4_location_if([ (void) yylocationp; + YYUSE (yyvaluep); +b4_location_if([ YYUSE (yylocationp); ])dnl [ if (yytype < YYNTOKENS) diff --git a/data/glr.c b/data/glr.c index 848579b6..877e4009 100644 --- a/data/glr.c +++ b/data/glr.c @@ -234,6 +234,9 @@ b4_syncline([@oline@], [@ofile@]) # endif #endif +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) do {;} while (/*CONSTCOND*/ yyfalse && (e)) + #ifndef YYFREE # define YYFREE free #endif @@ -470,7 +473,7 @@ static const ]b4_int_type_for([b4_stos])[ yystos[] = (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ - while (0) + while (/*CONSTCOND*/ 0) /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know @@ -515,7 +518,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; #define YYCHK(YYE) \ do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \ - while (0) + while (/*CONSTCOND*/ 0) #if YYDEBUG @@ -527,7 +530,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG; do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (/*CONSTCOND*/ 0) ]b4_yysymprint_generate([b4_c_ansi_function_def])[ @@ -540,7 +543,7 @@ do { \ Type, Value]b4_location_if([, Location])[); \ YYFPRINTF (stderr, "\n"); \ } \ -} while (0) +} while (/*CONSTCOND*/ 0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -877,9 +880,8 @@ b4_syncline([@oline@], [@ofile@]) static void yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1) { - /* Suppress unused-variable warnings. */ - yy0 = yy0; - yy1 = yy1; + YYUSE (yy0); + YYUSE (yy1); switch (yyn) { @@ -1306,7 +1308,7 @@ yydoAction (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule, do { \ if (yydebug) \ yy_reduce_print (K, Rule); \ -} while (0) +} while (/*CONSTCOND*/ 0) /*----------------------------------------------------------. | Report that the RULE is going to be reduced on stack #K. | @@ -1621,9 +1623,8 @@ static void yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1, yyGLRStack* yystack]b4_pure_formals[) { - /* Suppress unused-variable warnings. */ - yyx0 = yyx0; - yyx1 = yyx1; + YYUSE (yyx0); + YYUSE (yyx1); #if YYDEBUG YYFPRINTF (stderr, "Ambiguity detected.\n"); @@ -1836,9 +1837,8 @@ static void yyreportSyntaxError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[) { - /* Suppress unused-variable warnings. */ - yylvalp = yylvalp; - yyllocp = yyllocp; + YYUSE (yylvalp); + YYUSE (yyllocp); if (yystack->yyerrState == 0) { @@ -2046,7 +2046,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack, default: \ goto yybuglab; \ } \ - } while (0) + } while (/*CONSTCOND*/ 0) /*----------. diff --git a/data/lalr1.cc b/data/lalr1.cc index 01fbcd0f..91bc2ec4 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -88,7 +88,7 @@ do { \ { \ (Current).begin = (Current).end = (Rhs)[0].end; \ } \ -} while (0) +} while (false) #endif namespace yy @@ -319,6 +319,9 @@ b4_syncline([@oline@], [@ofile@])[ # endif #endif +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) do {;} while (false && (e)) + /* A pseudo ostream that takes yydebug_ into account. */ # define YYCDEBUG \ for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \ @@ -335,19 +338,19 @@ do { \ yysymprint_ ((Type), (Value), (Location)); \ *yycdebug_ << std::endl; \ } \ -} while (0) +} while (false) # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug_) \ yyreduce_print_ (Rule); \ -} while (0) +} while (false) # define YY_STACK_PRINT() \ do { \ if (yydebug_) \ yystack_print_ (); \ -} while (0) +} while (false) #else /* !YYDEBUG */ @@ -414,9 +417,9 @@ yy::]b4_parser_class_name[::yysymprint_ (int yytype, /* Backward compatibility, but should be removed eventually. */ std::ostream& cdebug_ = *yycdebug_; - /* Suppress unused-variable warnings. */ - if (false) - yysymprint_ (yytype + !&cdebug_, yyvaluep, yylocationp); + YYUSE (!&cdebug_); + YYUSE (yylocationp); + YYUSE (yyvaluep); *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") << ' ' << yytname_[yytype] << " (" @@ -435,9 +438,9 @@ void yy::]b4_parser_class_name[::yydestruct_ (const char* yymsg, int yytype, semantic_type* yyvaluep, location_type* yylocationp) { - /* Suppress unused-variable warnings. */ - if (false) - yydestruct_ (yymsg, yytype, yyvaluep, yylocationp); + YYUSE (yylocationp); + YYUSE (yymsg); + YYUSE (yyvaluep); YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); diff --git a/data/yacc.c b/data/yacc.c index cbce25b1..1a141108 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -246,6 +246,9 @@ b4_syncline([@oline@], [@ofile@])[ # endif #endif +/* Suppress unused-variable warnings by "using" E. */ +#define YYUSE(e) do {;} while (/*CONSTCOND*/ 0 && (e)) + #if ! defined (yyoverflow) || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -355,7 +358,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ - while (0) + while (/*CONSTCOND*/ 0) # endif # endif @@ -373,7 +376,7 @@ union yyalloc yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (0) + while (/*CONSTCOND*/ 0) #endif @@ -544,7 +547,7 @@ do \ yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (0) +while (/*CONSTCOND*/ 0) #define YYTERROR 1 @@ -573,7 +576,7 @@ while (0) (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ - while (0) + while (/*CONSTCOND*/ 0) #endif @@ -613,7 +616,7 @@ while (0) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (/*CONSTCOND*/ 0) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ @@ -624,7 +627,7 @@ do { \ Type, Value]b4_location_if([, Location])[); \ YYFPRINTF (stderr, "\n"); \ } \ -} while (0) +} while (/*CONSTCOND*/ 0) /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | @@ -645,7 +648,7 @@ do { \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (0) +} while (/*CONSTCOND*/ 0) /*------------------------------------------------. @@ -669,7 +672,7 @@ do { \ do { \ if (yydebug) \ yy_reduce_print (Rule); \ -} while (0) +} while (/*CONSTCOND*/ 0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -1351,7 +1354,7 @@ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ - if (0) + if (/*CONSTCOND*/ 0) goto yyerrorlab; ]b4_location_if([[ yyerror_range[0] = yylsp[1-yylen]; -- 2.47.2