c++: more YY_NULL

Caught by maintainer-check-g++.
* data/glr.c, data/lalr1.cc, data/yacc.c, tests/cxx-type.at,
* tests/glr-regression.at, tests/push.at:
When simple to do, avoid expliciting the null ptr.
Otherwise use YY_NULL.
This commit is contained in:
Akim Demaille
2012-04-01 13:15:41 +02:00
parent 3e75a2c92b
commit eeaf1dc646
6 changed files with 28 additions and 28 deletions

View File

@@ -829,7 +829,7 @@ yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
else else
/* The effect of using yysval or yyloc (in an immediate rule) is /* The effect of using yysval or yyloc (in an immediate rule) is
* undefined. */ * undefined. */
yyvsp[i].yystate.yysemantics.yyfirstVal = NULL; yyvsp[i].yystate.yysemantics.yyfirstVal = YY_NULL;
yyvsp[i].yystate.yyloc = s->yyloc; yyvsp[i].yystate.yyloc = s->yyloc;
s = yyvsp[i].yystate.yypred = s->yypred; s = yyvsp[i].yystate.yypred = s->yypred;
} }
@@ -1434,7 +1434,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
YYLTYPE yyloc;])[ YYLTYPE yyloc;])[
yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[); yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
if (yyflag == yyerr && yystackp->yysplitPoint != NULL) if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULL)
{ {
YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n", YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
(unsigned long int) yyk, yyrule - 1)); (unsigned long int) yyk, yyrule - 1));

View File

@@ -715,7 +715,7 @@ m4_popdef([b4_at_dollar])])dnl
location values to have been already stored, initialize these location values to have been already stored, initialize these
stacks with a primary value. */ stacks with a primary value. */
yystack_ = stack_type (0); yystack_ = stack_type (0);
yypush_ (0, 0, yyla); yypush_ (YY_NULL, 0, yyla);
// A new symbol was pushed on the stack. // A new symbol was pushed on the stack.
yynewstate: yynewstate:
@@ -853,14 +853,14 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
// in the debug trace, it's possibly junk. Hence yymsg = 0. // in the debug trace, it's possibly junk. Hence yymsg = 0.
// Besides, that keeps exactly the same traces as with the other // Besides, that keeps exactly the same traces as with the other
// Bison skeletons. // Bison skeletons.
yy_destroy_ (0, yystack_[i]);]])[ yy_destroy_ (YY_NULL, yystack_[i]);]])[
yypop_ (yylen); yypop_ (yylen);
yylen = 0; yylen = 0;
YY_STACK_PRINT (); YY_STACK_PRINT ();
/* Shift the result of the reduction. */ /* Shift the result of the reduction. */
yypush_ (0, yylhs); yypush_ (YY_NULL, yylhs);
goto yynewstate; goto yynewstate;
/*--------------------------------------. /*--------------------------------------.

View File

@@ -1179,12 +1179,12 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes, ]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes,
YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken) YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken)
{ {
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
YYSIZE_T yysize = yysize0; YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1; YYSIZE_T yysize1;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */ /* Internationalized format string. */
const char *yyformat = 0; const char *yyformat = YY_NULL;
/* Arguments of yyformat. */ /* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per /* Number of reported tokens (one for the "unexpected", one per
@@ -1262,7 +1262,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
break; break;
} }
yyarg[yycount++] = yytname[yyx]; yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
if (! (yysize <= yysize1 if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM)) && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2; return 2;
@@ -1351,7 +1351,7 @@ static char yypstate_allocated = 0;]])b4_pull_if([
b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
{ {
return yypull_parse (0]m4_ifset([b4_parse_param], return yypull_parse (YY_NULL]m4_ifset([b4_parse_param],
[[, ]b4_c_args(b4_parse_param)])[); [[, ]b4_c_args(b4_parse_param)])[);
} }
@@ -1364,7 +1364,9 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
int yychar; int yychar;
YYSTYPE yylval;]b4_locations_if([[ YYSTYPE yylval;]b4_locations_if([[
YYLTYPE yylloc;]])])[ YYLTYPE yylloc;]])])[
if (yyps == 0) if (yyps)
yyps_local = yyps;
else
{ {
yyps_local = yypstate_new (); yyps_local = yypstate_new ();
if (!yyps_local) if (!yyps_local)
@@ -1375,14 +1377,12 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
return 2; return 2;
} }
} }
else
yyps_local = yyps;
do { do {
yychar = YYLEX; yychar = YYLEX;
yystatus = yystatus =
yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[); yypush_parse (yyps_local]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_c_args(b4_parse_param)])[);
} while (yystatus == YYPUSH_MORE); } while (yystatus == YYPUSH_MORE);
if (yyps == 0) if (!yyps)
yypstate_delete (yyps_local); yypstate_delete (yyps_local);
return yystatus; return yystatus;
}]])[ }]])[
@@ -1392,10 +1392,10 @@ b4_c_function_def([[yyparse]], [[int]], b4_parse_param)[
{ {
yypstate *yyps;]b4_pure_if([], [[ yypstate *yyps;]b4_pure_if([], [[
if (yypstate_allocated) if (yypstate_allocated)
return 0;]])[ return YY_NULL;]])[
yyps = (yypstate *) malloc (sizeof *yyps); yyps = (yypstate *) malloc (sizeof *yyps);
if (!yyps) if (!yyps)
return 0; return YY_NULL;
yyps->yynew = 1;]b4_pure_if([], [[ yyps->yynew = 1;]b4_pure_if([], [[
yypstate_allocated = 1;]])[ yypstate_allocated = 1;]])[
return yyps; return yyps;

View File

@@ -105,19 +105,19 @@ prog :
stmt : expr ';' $2 { $$ = ]$[1; } stmt : expr ';' $2 { $$ = ]$[1; }
| decl $3 | decl $3
| error ';' { $$ = new_nterm ("<error>", 0, 0, 0); } | error ';' { $$ = new_nterm ("<error>", YY_NULL, YY_NULL, YY_NULL); }
| '@' { YYACCEPT; } | '@' { YYACCEPT; }
; ;
expr : ID expr : ID
| TYPENAME '(' expr ')' | TYPENAME '(' expr ')'
{ $$ = new_nterm ("<cast>(%s,%s)", ]$[3, ]$[1, 0); } { $$ = new_nterm ("<cast>(%s,%s)", ]$[3, ]$[1, YY_NULL); }
| expr '+' expr { $$ = new_nterm ("+(%s,%s)", ]$[1, ]$[3, 0); } | expr '+' expr { $$ = new_nterm ("+(%s,%s)", ]$[1, ]$[3, YY_NULL); }
| expr '=' expr { $$ = new_nterm ("=(%s,%s)", ]$[1, ]$[3, 0); } | expr '=' expr { $$ = new_nterm ("=(%s,%s)", ]$[1, ]$[3, YY_NULL); }
; ;
decl : TYPENAME declarator ';' decl : TYPENAME declarator ';'
{ $$ = new_nterm ("<declare>(%s,%s)", ]$[1, ]$[2, 0); } { $$ = new_nterm ("<declare>(%s,%s)", ]$[1, ]$[2, YY_NULL); }
| TYPENAME declarator '=' expr ';' | TYPENAME declarator '=' expr ';'
{ $$ = new_nterm ("<init-declare>(%s,%s,%s)", ]$[1, { $$ = new_nterm ("<init-declare>(%s,%s,%s)", ]$[1,
]$[2, ]$[4); } ]$[2, ]$[4); }
@@ -209,7 +209,7 @@ yylex (LEX_PARAMETERS)
{ {
colNum += 1; colNum += 1;
tok = c; tok = c;
yylval = 0; yylval = YY_NULL;
} }
#if YYLSP_NEEDED #if YYLSP_NEEDED
yylloc.last_column = colNum-1; yylloc.last_column = colNum-1;
@@ -314,7 +314,7 @@ m4_bmatch([$2], [stmtMerge],
[[static YYSTYPE [[static YYSTYPE
stmtMerge (YYSTYPE x0, YYSTYPE x1) stmtMerge (YYSTYPE x0, YYSTYPE x1)
{ {
return new_nterm ("<OR>(%s,%s)", x0, x1, 0); return new_nterm ("<OR>(%s,%s)", x0, x1, YY_NULL);
} }
]]) ]])
) )

View File

@@ -298,7 +298,7 @@ static void yyerror(char const * s) {
fprintf(stderr,"error: %s\n",s); fprintf(stderr,"error: %s\n",s);
} }
FILE *input = NULL; FILE *input = YY_NULL;
int P[] = { P1, P2 }; int P[] = { P1, P2 };
int O[] = { O1, O2 }; int O[] = { O1, O2 };

View File

@@ -60,12 +60,12 @@ main (void)
/* yypstate_delete used to leak ps->yyss if the stack was reallocated but the /* yypstate_delete used to leak ps->yyss if the stack was reallocated but the
parse did not return on success, syntax error, or memory exhaustion. */ parse did not return on success, syntax error, or memory exhaustion. */
ps = yypstate_new (); ps = yypstate_new ();
assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE); assert (yypush_parse (ps, 'a', YY_NULL) == YYPUSH_MORE);
yypstate_delete (ps); yypstate_delete (ps);
ps = yypstate_new (); ps = yypstate_new ();
assert (yypush_parse (ps, 'a', NULL) == YYPUSH_MORE); assert (yypush_parse (ps, 'a', YY_NULL) == YYPUSH_MORE);
assert (yypush_parse (ps, 'b', NULL) == YYPUSH_MORE); assert (yypush_parse (ps, 'b', YY_NULL) == YYPUSH_MORE);
yypstate_delete (ps); yypstate_delete (ps);
return 0; return 0;
@@ -124,11 +124,11 @@ main (void)
{ {
ps = yypstate_new (); ps = yypstate_new ();
assert (ps); assert (ps);
assert (yypstate_new () == NULL); assert (yypstate_new () == YY_NULL);
]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[; ]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
yychar = 0; yychar = 0;
assert (yypush_parse (ps) == 0); assert (yypush_parse (ps) == 0);
assert (yypstate_new () == NULL); assert (yypstate_new () == YY_NULL);
]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[; ]m4_if([$1], [[both]], [[assert (yyparse () == 2)]])[;
yypstate_delete (ps); yypstate_delete (ps);
} }