From beadb220d541df706f9e27997c3942433550620c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 9 Feb 2012 14:02:22 +0100 Subject: [PATCH] skeletons: simplify the protections against "unused" warnings. * data/c.m4 (b4_parse_param_use): Also accept optional arguments to "use". Simplify callers. * data/glr.c (yyuserAction): Simplify use of b4_parse_param_use. (yy_reduce_print): Don't use b4_parse_param_use, as all the arguments _are_ used. * data/lalr1.cc (YY_SYMBOL_PRINT): Even when disabled, "use" the symbol argument. This neutralizes a warning in yypush_ when there are no symbols with a semantic values. (yy_destroy_): Remove useless "use" of yymsg. --- data/c.m4 | 26 +++++++++++--------------- data/glr.c | 7 +++---- data/lalr1.cc | 3 +-- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/data/c.m4 b/data/c.m4 index d09d1f1c..0649e62f 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -120,11 +120,15 @@ m4_popdef([$2])dnl m4_popdef([$1])dnl ])]) -# b4_parse_param_use -# ------------------ -# `YYUSE' all the parse-params. +# b4_parse_param_use([VAL], [LOC]) +# -------------------------------- +# `YYUSE' VAL, LOC if locations are enabled, and all the parse-params. m4_define([b4_parse_param_use], -[b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal); +[m4_ifval([$1], [ YYUSE([$1]); +])dnl +m4_ifval([$2], [b4_locations_if([ YYUSE ([$2]); +])])dnl +b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal); ])dnl ]) @@ -444,11 +448,7 @@ m4_define_default([b4_yydestruct_generate], b4_locations_if( [, [[YYLTYPE *yylocationp], [yylocationp]]])[]dnl m4_ifset([b4_parse_param], [, b4_parse_param]))[ { - YYUSE (yyvaluep); -]b4_locations_if([ YYUSE (yylocationp); -])dnl -b4_parse_param_use[]dnl -[ +]b4_parse_param_use([yyvaluep], [yylocationp])[ if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); @@ -485,14 +485,10 @@ m4_ifset([b4_parse_param], [, b4_parse_param]))[ { if (!yyvaluep) return; -]b4_locations_if([ YYUSE (yylocationp); -])dnl -b4_parse_param_use[]dnl -[# ifdef YYPRINT +]b4_parse_param_use([yyoutput], [yylocationp])[ +# ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); # endif switch (yytype) { diff --git a/data/glr.c b/data/glr.c index 9a3dbc8d..9b525f47 100644 --- a/data/glr.c +++ b/data/glr.c @@ -852,8 +852,8 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, yybool yynormal __attribute__ ((__unused__)) = (yystackp->yysplitPoint == NULL); int yylow; -]b4_parse_param_use[]dnl -[# undef yyerrok +]b4_parse_param_use([yyvalp], [yylocp])[ +# undef yyerrok # define yyerrok (yystackp->yyerrState = 0) # undef YYACCEPT # define YYACCEPT return yyaccept @@ -1330,8 +1330,7 @@ yy_reduce_print (int yynormal, yyGLRStackItem* yyvsp, size_t yyk, int yynrhs = yyrhsLength (yyrule);]b4_locations_if([ int yylow = 1;])[ int yyi; -]b4_parse_param_use[]dnl -[ YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n", (unsigned long int) yyk, yyrule - 1, (unsigned long int) yyrline[yyrule]); if (! yynormal) diff --git a/data/lalr1.cc b/data/lalr1.cc index 8afabc21..607d0e3c 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -441,7 +441,7 @@ b4_percent_code_get[]dnl #else /* !YYDEBUG */ # define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Symbol) static_cast(0) +# define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol) # define YY_REDUCE_PRINT(Rule) static_cast(0) # define YY_STACK_PRINT() static_cast(0) @@ -545,7 +545,6 @@ b4_percent_code_get[]dnl symbol_base_type& yysym) const { int yytype = yysym.type_get (); - YYUSE (yymsg); if (yymsg) YY_SYMBOL_PRINT (yymsg, yysym); -- 2.45.2