c++: use nullptr for C++11.

C++11 introduces "nullptr" which plays the role of C's NULL, in
replacement of "0".  Fix the C++ skeletons to avoid warnings about
uses of "0" in place of "nullptr", and improve C skeletons to also use
this "nullptr" when compiled with a C++11 compiler.

* configure.ac: More C++ warnings.
* NEWS (2.5.1): Document this.
* data/c++.m4, data/c.m4 (b4_null_define): New.
(b4_null): Use YY_NULL instead of 0.
* data/glr.c, data/lalr1.cc, data/location.cc, data/yacc.c:
Call b4_null_define/b4_null where appropriate.
Use YY_NULL instead of NULL.
* data/location.cc (initialize): Accept a default argument,
YY_NULL.
* tests/actions.at, tests/calc.at: Adjust.

* data/glr.c, lib/libiberty.h, src/system.h (__attribute__):
Do not disable it when __STRICT_ANSI__ is defined, as, for
instance, it disables the __attribute__((unused)) which
protects us from some compiler warnings.
This was already done elsewhere in Bison, in 2001, see
4a0d893695.
* tests/regression.at: Adjust output.
This commit is contained in:
Akim Demaille
2012-03-30 15:50:45 +02:00
parent e85056ef5f
commit ef51bfa744
13 changed files with 105 additions and 73 deletions

8
NEWS
View File

@@ -9,6 +9,9 @@ Bison News
tools such as diff, warning messages from the test suite itself, tools such as diff, warning messages from the test suite itself,
etc. etc.
__attribute__ is not longer disabled when __STRICT_ANSI__ is defined
(i.e., when -std is passed to GCC).
** Warnings during the build procedure have been eliminated. ** Warnings during the build procedure have been eliminated.
** Many minor improvements have been made to the manual: ** Many minor improvements have been made to the manual:
@@ -26,6 +29,11 @@ Bison News
The Java parser no longer throws ArrayIndexOutOfBoundsException if The Java parser no longer throws ArrayIndexOutOfBoundsException if
the first token leads to a syntax error. Some minor clean ups. the first token leads to a syntax error. Some minor clean ups.
** C++11 compatibility:
C and C++ parsers use nullptr instead of 0 when __cplusplus is
201103L or higher.
* Changes in version 2.5 (2011-05-14): * Changes in version 2.5 (2011-05-14):
** Grammar symbol names can now contain non-initial dashes: ** Grammar symbol names can now contain non-initial dashes:

View File

@@ -70,7 +70,7 @@ if test "$enable_gcc_warnings" = yes; then
-Wcast-qual -Wformat -Wpointer-arith -Wwrite-strings' -Wcast-qual -Wformat -Wpointer-arith -Wwrite-strings'
warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes
-Wshadow -Wstrict-prototypes' -Wshadow -Wstrict-prototypes'
warn_cxx='' warn_cxx='-Wnoexcept -Wzero-as-null-pointer-constant'
AC_LANG_PUSH([C]) AC_LANG_PUSH([C])
for i in $warn_common $warn_c; for i in $warn_common $warn_c;
do do

View File

@@ -97,6 +97,8 @@ m4_map_sep([ b4_token_enum], [,
]) ])
## ----------------- ## ## ----------------- ##
## Semantic Values. ## ## Semantic Values. ##
## ----------------- ## ## ----------------- ##

View File

@@ -146,16 +146,31 @@ m4_define([b4_table_value_equals],
[[YYID (0)]], [[YYID (0)]],
[[((]$2[) == (]$3[))]])]) [[((]$2[) == (]$3[))]])])
## ---------## ## ---------##
## Values. ## ## Values. ##
## ---------## ## ---------##
# b4_null
---------
# Return a null pointer constant. NULL infringes on the user name
# space in C, so use 0 rather than NULL.
m4_define([b4_null], [0])
# b4_null_define
# --------------
# Portability issues: define a YY_NULL appropriate for the current
# language (C, C++98, or C++11).
m4_define([b4_null_define],
[# ifndef YY_NULL
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULL nullptr
# else
# define YY_NULL 0
# endif
# endif[]dnl
])
# b4_null
# -------
# Return a null pointer constant.
m4_define([b4_null], [YY_NULL])

View File

@@ -171,6 +171,8 @@ m4_if(b4_prefix, [yy], [],
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
]b4_user_pre_prologue ]b4_user_pre_prologue
b4_null_define
dnl # b4_shared_declarations dnl # b4_shared_declarations
dnl # ---------------------- dnl # ----------------------
dnl # Declaration that might either go into the header (if --defines) dnl # Declaration that might either go into the header (if --defines)
@@ -310,8 +312,7 @@ b4_percent_code_get[]dnl
#ifndef __attribute__ #ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */ /* This feature is available in gcc versions 2.5 and later. */
# if (! defined __GNUC__ || __GNUC__ < 2 \ # if (! defined __GNUC__ || __GNUC__ < 2 \
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5) \ || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
|| (defined __STRICT_ANSI__ && __STRICT_ANSI__))
# define __attribute__(Spec) /* empty */ # define __attribute__(Spec) /* empty */
# endif # endif
#endif #endif
@@ -827,7 +828,7 @@ static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
static void static void
yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg) yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg)
{ {
if (yymsg != NULL) if (yymsg != YY_NULL)
yyerror (]b4_yyerror_args[yymsg); yyerror (]b4_yyerror_args[yymsg);
YYLONGJMP (yystackp->yyexception_buffer, 1); YYLONGJMP (yystackp->yyexception_buffer, 1);
} }
@@ -901,7 +902,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
]b4_user_formals[) ]b4_user_formals[)
{ {
yybool yynormal __attribute__ ((__unused__)) = yybool yynormal __attribute__ ((__unused__)) =
(yystackp->yysplitPoint == NULL); (yystackp->yysplitPoint == YY_NULL);
int yylow; int yylow;
]b4_parse_param_use[]dnl ]b4_parse_param_use[]dnl
[# undef yyerrok [# undef yyerrok
@@ -988,7 +989,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[)
else else
YYFPRINTF (stderr, "%s incomplete ", yymsg); YYFPRINTF (stderr, "%s incomplete ", yymsg);
yy_symbol_print (stderr, yystos[yys->yylrState], yy_symbol_print (stderr, yystos[yys->yylrState],
NULL]b4_locations_if([, &yys->yyloc])[]b4_user_args[); YY_NULL]b4_locations_if([, &yys->yyloc])[]b4_user_args[);
YYFPRINTF (stderr, "\n"); YYFPRINTF (stderr, "\n");
} }
#endif #endif
@@ -1141,7 +1142,7 @@ yyinitStateSet (yyGLRStateSet* yyset)
yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]); yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
if (! yyset->yystates) if (! yyset->yystates)
return yyfalse; return yyfalse;
yyset->yystates[0] = NULL; yyset->yystates[0] = YY_NULL;
yyset->yylookaheadNeeds = yyset->yylookaheadNeeds =
(yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]); (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]);
if (! yyset->yylookaheadNeeds) if (! yyset->yylookaheadNeeds)
@@ -1171,8 +1172,8 @@ yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
if (!yystackp->yyitems) if (!yystackp->yyitems)
return yyfalse; return yyfalse;
yystackp->yynextFree = yystackp->yyitems; yystackp->yynextFree = yystackp->yyitems;
yystackp->yysplitPoint = NULL; yystackp->yysplitPoint = YY_NULL;
yystackp->yylastDeleted = NULL; yystackp->yylastDeleted = YY_NULL;
return yyinitStateSet (&yystackp->yytops); return yyinitStateSet (&yystackp->yytops);
} }
@@ -1211,10 +1212,10 @@ yyexpandGLRStack (yyGLRStack* yystackp)
{ {
yyGLRState* yys0 = &yyp0->yystate; yyGLRState* yys0 = &yyp0->yystate;
yyGLRState* yys1 = &yyp1->yystate; yyGLRState* yys1 = &yyp1->yystate;
if (yys0->yypred != NULL) if (yys0->yypred != YY_NULL)
yys1->yypred = yys1->yypred =
YYRELOC (yyp0, yyp1, yys0->yypred, yystate); YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != NULL) if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL)
yys1->yysemantics.yyfirstVal = yys1->yysemantics.yyfirstVal =
YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption); YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
} }
@@ -1222,18 +1223,18 @@ yyexpandGLRStack (yyGLRStack* yystackp)
{ {
yySemanticOption* yyv0 = &yyp0->yyoption; yySemanticOption* yyv0 = &yyp0->yyoption;
yySemanticOption* yyv1 = &yyp1->yyoption; yySemanticOption* yyv1 = &yyp1->yyoption;
if (yyv0->yystate != NULL) if (yyv0->yystate != YY_NULL)
yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate); yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
if (yyv0->yynext != NULL) if (yyv0->yynext != YY_NULL)
yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption); yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
} }
} }
if (yystackp->yysplitPoint != NULL) if (yystackp->yysplitPoint != YY_NULL)
yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems, yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems,
yystackp->yysplitPoint, yystate); yystackp->yysplitPoint, yystate);
for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1) for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1)
if (yystackp->yytops.yystates[yyn] != NULL) if (yystackp->yytops.yystates[yyn] != YY_NULL)
yystackp->yytops.yystates[yyn] = yystackp->yytops.yystates[yyn] =
YYRELOC (yystackp->yyitems, yynewItems, YYRELOC (yystackp->yyitems, yynewItems,
yystackp->yytops.yystates[yyn], yystate); yystackp->yytops.yystates[yyn], yystate);
@@ -1257,7 +1258,7 @@ yyfreeGLRStack (yyGLRStack* yystackp)
static inline void static inline void
yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys) yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
{ {
if (yystackp->yysplitPoint != NULL && yystackp->yysplitPoint > yys) if (yystackp->yysplitPoint != YY_NULL && yystackp->yysplitPoint > yys)
yystackp->yysplitPoint = yys; yystackp->yysplitPoint = yys;
} }
@@ -1265,9 +1266,9 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
static inline void static inline void
yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk) yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
{ {
if (yystackp->yytops.yystates[yyk] != NULL) if (yystackp->yytops.yystates[yyk] != YY_NULL)
yystackp->yylastDeleted = yystackp->yytops.yystates[yyk]; yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
yystackp->yytops.yystates[yyk] = NULL; yystackp->yytops.yystates[yyk] = YY_NULL;
} }
/** Undelete the last stack that was marked as deleted. Can only be /** Undelete the last stack that was marked as deleted. Can only be
@@ -1276,12 +1277,12 @@ yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
static void static void
yyundeleteLastStack (yyGLRStack* yystackp) yyundeleteLastStack (yyGLRStack* yystackp)
{ {
if (yystackp->yylastDeleted == NULL || yystackp->yytops.yysize != 0) if (yystackp->yylastDeleted == YY_NULL || yystackp->yytops.yysize != 0)
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")); YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
yystackp->yylastDeleted = NULL; yystackp->yylastDeleted = YY_NULL;
} }
static inline void static inline void
@@ -1291,7 +1292,7 @@ yyremoveDeletes (yyGLRStack* yystackp)
yyi = yyj = 0; yyi = yyj = 0;
while (yyj < yystackp->yytops.yysize) while (yyj < yystackp->yytops.yysize)
{ {
if (yystackp->yytops.yystates[yyi] == NULL) if (yystackp->yytops.yystates[yyi] == YY_NULL)
{ {
if (yyi == yyj) if (yyi == yyj)
{ {
@@ -1353,7 +1354,7 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
yynewState->yyposn = yyposn; yynewState->yyposn = yyposn;
yynewState->yyresolved = yyfalse; yynewState->yyresolved = yyfalse;
yynewState->yypred = yystackp->yytops.yystates[yyk]; yynewState->yypred = yystackp->yytops.yystates[yyk];
yynewState->yysemantics.yyfirstVal = NULL; yynewState->yysemantics.yyfirstVal = YY_NULL;
yystackp->yytops.yystates[yyk] = yynewState; yystackp->yytops.yystates[yyk] = yynewState;
/* Invokes YY_RESERVE_GLRSTACK. */ /* Invokes YY_RESERVE_GLRSTACK. */
@@ -1372,7 +1373,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
{ {
int yynrhs = yyrhsLength (yyrule); int yynrhs = yyrhsLength (yyrule);
if (yystackp->yysplitPoint == NULL) if (yystackp->yysplitPoint == YY_NULL)
{ {
/* Standard special case: single stack. */ /* Standard special case: single stack. */
yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; yyGLRStackItem* rhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
@@ -1428,7 +1429,7 @@ yy_reduce_print (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
{ {
int yynrhs = yyrhsLength (yyrule); int yynrhs = yyrhsLength (yyrule);
yybool yynormal __attribute__ ((__unused__)) = yybool yynormal __attribute__ ((__unused__)) =
(yystackp->yysplitPoint == NULL); (yystackp->yysplitPoint == YY_NULL);
yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
int yylow = 1; int yylow = 1;
int yyi; int yyi;
@@ -1468,7 +1469,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
{ {
size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn; size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
if (yyforceEval || yystackp->yysplitPoint == NULL) if (yyforceEval || yystackp->yysplitPoint == YY_NULL)
{ {
YYSTYPE yysval; YYSTYPE yysval;
YYLTYPE yyloc; YYLTYPE yyloc;
@@ -1501,7 +1502,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
"Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n", "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
(unsigned long int) yyk, yyrule - 1, yynewLRState)); (unsigned long int) yyk, yyrule - 1, 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] != NULL) if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULL)
{ {
yyGLRState* yyp, *yysplit = yystackp->yysplitPoint; yyGLRState* yyp, *yysplit = yystackp->yysplitPoint;
yyp = yystackp->yytops.yystates[yyi]; yyp = yystackp->yytops.yystates[yyi];
@@ -1528,7 +1529,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
static size_t static size_t
yysplitStack (yyGLRStack* yystackp, size_t yyk) yysplitStack (yyGLRStack* yystackp, size_t yyk)
{ {
if (yystackp->yysplitPoint == NULL) if (yystackp->yysplitPoint == YY_NULL)
{ {
YYASSERT (yyk == 0); YYASSERT (yyk == 0);
yystackp->yysplitPoint = yystackp->yytops.yystates[yyk]; yystackp->yysplitPoint = yystackp->yytops.yystates[yyk];
@@ -1538,7 +1539,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
yyGLRState** yynewStates; yyGLRState** yynewStates;
yybool* yynewLookaheadNeeds; yybool* yynewLookaheadNeeds;
yynewStates = NULL; yynewStates = YY_NULL;
if (yystackp->yytops.yycapacity if (yystackp->yytops.yycapacity
> (YYSIZEMAX / (2 * sizeof yynewStates[0]))) > (YYSIZEMAX / (2 * sizeof yynewStates[0])))
@@ -1549,7 +1550,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
(yyGLRState**) YYREALLOC (yystackp->yytops.yystates, (yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
(yystackp->yytops.yycapacity (yystackp->yytops.yycapacity
* sizeof yynewStates[0])); * sizeof yynewStates[0]));
if (yynewStates == NULL) if (yynewStates == YY_NULL)
yyMemoryExhausted (yystackp); yyMemoryExhausted (yystackp);
yystackp->yytops.yystates = yynewStates; yystackp->yytops.yystates = yynewStates;
@@ -1557,7 +1558,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
(yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds, (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
(yystackp->yytops.yycapacity (yystackp->yytops.yycapacity
* sizeof yynewLookaheadNeeds[0])); * sizeof yynewLookaheadNeeds[0]));
if (yynewLookaheadNeeds == NULL) if (yynewLookaheadNeeds == YY_NULL)
yyMemoryExhausted (yystackp); yyMemoryExhausted (yystackp);
yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds; yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds;
} }
@@ -1623,9 +1624,9 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
yyz1 = yys1->yysemantics.yyfirstVal; yyz1 = yys1->yysemantics.yyfirstVal;
while (YYID (yytrue)) while (YYID (yytrue))
{ {
if (yyz1 == *yyz0p || yyz1 == NULL) if (yyz1 == *yyz0p || yyz1 == YY_NULL)
break; break;
else if (*yyz0p == NULL) else if (*yyz0p == YY_NULL)
{ {
*yyz0p = yyz1; *yyz0p = yyz1;
break; break;
@@ -1748,7 +1749,7 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred) for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
yystates[yyi] = yys; yystates[yyi] = yys;
if (yys == NULL) if (yys == YY_NULL)
{ {
yyleftmost_state.yyposn = 0; yyleftmost_state.yyposn = 0;
yystates[0] = &yyleftmost_state; yystates[0] = &yyleftmost_state;
@@ -1823,7 +1824,7 @@ yyresolveLocations (yyGLRState* yys1, int yyn1,
YYSTYPE yylval_current; YYSTYPE yylval_current;
YYLTYPE yylloc_current; YYLTYPE yylloc_current;
yyoption = yys1->yysemantics.yyfirstVal; yyoption = yys1->yysemantics.yyfirstVal;
YYASSERT (yyoption != NULL); YYASSERT (yyoption != YY_NULL);
yynrhs = yyrhsLength (yyoption->yyrule); yynrhs = yyrhsLength (yyoption->yyrule);
if (yynrhs > 0) if (yynrhs > 0)
{ {
@@ -1881,7 +1882,7 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
yybest = yyoptionList; yybest = yyoptionList;
yymerge = yyfalse; yymerge = yyfalse;
for (yypp = &yyoptionList->yynext; *yypp != NULL; ) for (yypp = &yyoptionList->yynext; *yypp != YY_NULL; )
{ {
yySemanticOption* yyp = *yypp; yySemanticOption* yyp = *yypp;
@@ -1924,7 +1925,7 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
yyflag = yyresolveAction (yybest, yystackp, &yysval, yyflag = yyresolveAction (yybest, yystackp, &yysval,
yylocp]b4_user_args[); yylocp]b4_user_args[);
if (yyflag == yyok) if (yyflag == yyok)
for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext) for (yyp = yybest->yynext; yyp != YY_NULL; yyp = yyp->yynext)
{ {
if (yyprec == yydprec[yyp->yyrule]) if (yyprec == yydprec[yyp->yyrule])
{ {
@@ -1952,14 +1953,14 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[)
yys->yysemantics.yysval = yysval; yys->yysemantics.yysval = yysval;
} }
else else
yys->yysemantics.yyfirstVal = NULL; yys->yysemantics.yyfirstVal = YY_NULL;
return yyflag; return yyflag;
} }
static YYRESULTTAG static YYRESULTTAG
yyresolveStack (yyGLRStack* yystackp]b4_user_formals[) yyresolveStack (yyGLRStack* yystackp]b4_user_formals[)
{ {
if (yystackp->yysplitPoint != NULL) if (yystackp->yysplitPoint != YY_NULL)
{ {
yyGLRState* yys; yyGLRState* yys;
int yyn; int yyn;
@@ -1979,10 +1980,10 @@ yycompressStack (yyGLRStack* yystackp)
{ {
yyGLRState* yyp, *yyq, *yyr; yyGLRState* yyp, *yyq, *yyr;
if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == NULL) if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == YY_NULL)
return; return;
for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL; for (yyp = yystackp->yytops.yystates[0], yyq = yyp->yypred, yyr = YY_NULL;
yyp != yystackp->yysplitPoint; yyp != yystackp->yysplitPoint;
yyr = yyp, yyp = yyq, yyq = yyp->yypred) yyr = yyp, yyp = yyq, yyq = yyp->yypred)
yyp->yypred = yyr; yyp->yypred = yyr;
@@ -1990,10 +1991,10 @@ yycompressStack (yyGLRStack* yystackp)
yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems; yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1; yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems; yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
yystackp->yysplitPoint = NULL; yystackp->yysplitPoint = YY_NULL;
yystackp->yylastDeleted = NULL; yystackp->yylastDeleted = YY_NULL;
while (yyr != NULL) while (yyr != YY_NULL)
{ {
yystackp->yynextFree->yystate = *yyr; yystackp->yynextFree->yystate = *yyr;
yyr = yyr->yypred; yyr = yyr->yypred;
@@ -2012,7 +2013,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
const short int* yyconflicts; const short int* yyconflicts;
yyRuleNum yyrule; yyRuleNum yyrule;
while (yystackp->yytops.yystates[yyk] != NULL) while (yystackp->yytops.yystates[yyk] != YY_NULL)
{ {
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState; yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
YYDPRINTF ((stderr, "Stack %lu Entering state %d\n", YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
@@ -2094,14 +2095,14 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yyerror (]b4_lyyerror_args[YY_("syntax error")); yyerror (]b4_lyyerror_args[YY_("syntax error"));
#else #else
yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken)); size_t yysize0 = yytnamerr (YY_NULL, yytokenName (yytoken));
size_t yysize = yysize0; size_t yysize = yysize0;
size_t yysize1; size_t yysize1;
yybool yysize_overflow = yyfalse; yybool yysize_overflow = yyfalse;
char* yymsg = NULL; char* yymsg = YY_NULL;
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
@@ -2156,7 +2157,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
break; break;
} }
yyarg[yycount++] = yytokenName (yyx); yyarg[yycount++] = yytokenName (yyx);
yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx)); yysize1 = yysize + yytnamerr (YY_NULL, yytokenName (yyx));
yysize_overflow |= yysize1 < yysize; yysize_overflow |= yysize1 < yysize;
yysize = yysize1; yysize = yysize1;
} }
@@ -2230,7 +2231,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
{ {
yySymbol yytoken; yySymbol yytoken;
if (yychar == YYEOF) if (yychar == YYEOF)
yyFail (yystackp][]b4_lpure_args[, NULL); yyFail (yystackp][]b4_lpure_args[, YY_NULL);
if (yychar != YYEMPTY) if (yychar != YYEMPTY)
{]b4_locations_if([[ {]b4_locations_if([[
/* We throw away the lookahead, but the error range /* We throw away the lookahead, but the error range
@@ -2271,10 +2272,10 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
/* Reduce to one stack. */ /* Reduce to one stack. */
for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1) for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
if (yystackp->yytops.yystates[yyk] != NULL) if (yystackp->yytops.yystates[yyk] != YY_NULL)
break; break;
if (yyk >= yystackp->yytops.yysize) if (yyk >= yystackp->yytops.yysize)
yyFail (yystackp][]b4_lpure_args[, NULL); yyFail (yystackp][]b4_lpure_args[, YY_NULL);
for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1) for (yyk += 1; yyk < yystackp->yytops.yysize; yyk += 1)
yymarkStackDeleted (yystackp, yyk); yymarkStackDeleted (yystackp, yyk);
yyremoveDeletes (yystackp); yyremoveDeletes (yystackp);
@@ -2282,7 +2283,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
/* Now pop stack until we find a state that shifts the error token. */ /* Now pop stack until we find a state that shifts the error token. */
yystackp->yyerrState = 3; yystackp->yyerrState = 3;
while (yystackp->yytops.yystates[0] != NULL) while (yystackp->yytops.yystates[0] != YY_NULL)
{ {
yyGLRState *yys = yystackp->yytops.yystates[0]; yyGLRState *yys = yystackp->yytops.yystates[0];
yyj = yypact[yys->yylrState]; yyj = yypact[yys->yylrState];
@@ -2305,14 +2306,14 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
} }
} }
]b4_locations_if([[ yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[ ]b4_locations_if([[ yystackp->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
if (yys->yypred != NULL) if (yys->yypred != YY_NULL)
yydestroyGLRState ("Error: popping", yys]b4_user_args[); yydestroyGLRState ("Error: popping", yys]b4_user_args[);
yystackp->yytops.yystates[0] = yys->yypred; yystackp->yytops.yystates[0] = yys->yypred;
yystackp->yynextFree -= 1; yystackp->yynextFree -= 1;
yystackp->yyspaceLeft += 1; yystackp->yyspaceLeft += 1;
} }
if (yystackp->yytops.yystates[0] == NULL) if (yystackp->yytops.yystates[0] == YY_NULL)
yyFail (yystackp][]b4_lpure_args[, NULL); yyFail (yystackp][]b4_lpure_args[, YY_NULL);
} }
#define YYCHK1(YYE) \ #define YYCHK1(YYE) \
@@ -2564,7 +2565,7 @@ m4_popdef([b4_at_dollar])])dnl
{ {
yyGLRState *yys = yystates[yyk]; yyGLRState *yys = yystates[yyk];
]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]] ]b4_locations_if([[ yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
)[ if (yys->yypred != NULL) )[ if (yys->yypred != YY_NULL)
yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[); yydestroyGLRState ("Cleanup: popping", yys]b4_user_args[);
yystates[yyk] = yys->yypred; yystates[yyk] = yys->yypred;
yystack.yynextFree -= 1; yystack.yynextFree -= 1;
@@ -2601,7 +2602,7 @@ yy_yypstack (yyGLRState* yys)
static void static void
yypstates (yyGLRState* yyst) yypstates (yyGLRState* yyst)
{ {
if (yyst == NULL) if (yyst == YY_NULL)
YYFPRINTF (stderr, "<null>"); YYFPRINTF (stderr, "<null>");
else else
yy_yypstack (yyst); yy_yypstack (yyst);
@@ -2615,7 +2616,7 @@ yypstack (yyGLRStack* yystackp, size_t yyk)
} }
#define YYINDEX(YYX) \ #define YYINDEX(YYX) \
((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems) ((YYX) == YY_NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems)
static void static void

View File

@@ -51,6 +51,8 @@ dnl FIXME: This is wrong, we want computed header guards.
]b4_percent_define_ifdef([[location_type]], [], ]b4_percent_define_ifdef([[location_type]], [],
[[#include "location.hh"]])[ [[#include "location.hh"]])[
]b4_null_define[
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[ # define YYDEBUG ]b4_debug_flag[
@@ -931,7 +933,7 @@ b4_error_verbose_if([int yystate, int yytoken],
} }
} }
char const* yyformat = 0; char const* yyformat = YY_NULL;
switch (yycount) switch (yycount)
{ {
#define YYCASE_(N, S) \ #define YYCASE_(N, S) \

View File

@@ -20,7 +20,7 @@ m4_changecom()
m4_divert_push(0)dnl m4_divert_push(0)dnl
@output(b4_dir_prefix[]position.hh@)@ @output(b4_dir_prefix[]position.hh@)@
b4_copyright([Positions for Bison parsers in C++], b4_copyright([Positions for Bison parsers in C++],
[2002-2007, 2009-2011])[ [2002-2007, 2009-2012])[
/** /**
** \file position.hh ** \file position.hh
@@ -34,6 +34,8 @@ b4_copyright([Positions for Bison parsers in C++],
# include <string> # include <string>
# include <algorithm> # include <algorithm>
]b4_null_define[
]b4_namespace_open[ ]b4_namespace_open[
/// Abstract a position. /// Abstract a position.
class position class position
@@ -42,13 +44,13 @@ b4_copyright([Positions for Bison parsers in C++],
]m4_ifdef([b4_location_constructors], [ ]m4_ifdef([b4_location_constructors], [
/// Construct a position. /// Construct a position.
position () position ()
: filename (0), line (]b4_location_initial_line[), column (]b4_location_initial_column[) : filename (YY_NULL), line (]b4_location_initial_line[), column (]b4_location_initial_column[)
{ {
} }
])[ ])[
/// Initialization. /// Initialization.
inline void initialize (]b4_percent_define_get([[filename_type]])[* fn) inline void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL)
{ {
filename = fn; filename = fn;
line = ]b4_location_initial_line[; line = ]b4_location_initial_line[;
@@ -174,7 +176,7 @@ b4_copyright([Locations for Bison parsers in C++],
])[ ])[
/// Initialization. /// Initialization.
inline void initialize (]b4_percent_define_get([[filename_type]])[* fn) inline void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL)
{ {
begin.initialize (fn); begin.initialize (fn);
end = begin; end = begin;

View File

@@ -267,6 +267,8 @@ m4_if(b4_prefix, [yy], [],
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
]b4_user_pre_prologue[ ]b4_user_pre_prologue[
]b4_null_define[
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
# define YYDEBUG ]b4_debug_flag[ # define YYDEBUG ]b4_debug_flag[

View File

@@ -24,7 +24,7 @@
# define BISON_LIBIBERTY_H_ 1 # define BISON_LIBIBERTY_H_ 1
# ifndef __attribute__ # ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x) # define __attribute__(x)
# endif # endif
# endif # endif

View File

@@ -85,7 +85,7 @@ typedef size_t uintptr_t;
# ifndef __attribute__ # ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */ /* This feature is available in gcc versions 2.5 and later. */
# if (! defined __GNUC__ || __GNUC__ < 2 \ # if (! defined __GNUC__ || __GNUC__ < 2 \
|| (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
# define __attribute__(Spec) /* empty */ # define __attribute__(Spec) /* empty */
# endif # endif
# endif # endif

View File

@@ -345,7 +345,7 @@ thing:
; ;
%% %%
/* Alias to ARGV[1]. */ /* Alias to ARGV[1]. */
const char *source = 0; const char *source = YY_NULL;
static int static int
yylex (]AT_LEX_FORMALS[) yylex (]AT_LEX_FORMALS[)

View File

@@ -241,7 +241,7 @@ int yylex (]AT_LEX_FORMALS[);
are stored in a union, from which objects with constructors are are stored in a union, from which objects with constructors are
excluded in C++. */ excluded in C++. */
%initial-action { %initial-action {
@$.initialize (0); @$.initialize ();
} }
])])[ ])])[

View File

@@ -769,7 +769,7 @@ static const yytype_uint8 yyrline[] =
static const char *const yytname[] = static const char *const yytname[] =
{ {
"$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"", "$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"",
"\"else\"", "$accept", "statement", "struct_stat", "if", "else", 0 "\"else\"", "$accept", "statement", "struct_stat", "if", "else", YY_NULL
}; };
static const yytype_uint16 yytoknum[] = static const yytype_uint16 yytoknum[] =
{ {