From: Akim Demaille Date: Fri, 30 Mar 2012 13:50:45 +0000 (+0200) Subject: c++: use nullptr for C++11. X-Git-Tag: v2.5.1_rc2~68 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/ef51bfa744db744dc4b2eff1ba9d6334c807f8e6 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 4a0d89369599a2cea01f4fbdf791f426a02cb5a3. * tests/regression.at: Adjust output. --- diff --git a/NEWS b/NEWS index 838a6868..d972d85d 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ Bison News tools such as diff, warning messages from the test suite itself, 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. ** Many minor improvements have been made to the manual: @@ -26,6 +29,11 @@ Bison News The Java parser no longer throws ArrayIndexOutOfBoundsException if 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): ** Grammar symbol names can now contain non-initial dashes: diff --git a/configure.ac b/configure.ac index 78f641d3..210002b2 100644 --- a/configure.ac +++ b/configure.ac @@ -70,7 +70,7 @@ if test "$enable_gcc_warnings" = yes; then -Wcast-qual -Wformat -Wpointer-arith -Wwrite-strings' warn_c='-Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wshadow -Wstrict-prototypes' - warn_cxx='' + warn_cxx='-Wnoexcept -Wzero-as-null-pointer-constant' AC_LANG_PUSH([C]) for i in $warn_common $warn_c; do diff --git a/data/c++.m4 b/data/c++.m4 index 8470ebe9..9913a172 100644 --- a/data/c++.m4 +++ b/data/c++.m4 @@ -97,6 +97,8 @@ m4_map_sep([ b4_token_enum], [, ]) + + ## ----------------- ## ## Semantic Values. ## ## ----------------- ## diff --git a/data/c.m4 b/data/c.m4 index e0e58cdb..195c441d 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -146,16 +146,31 @@ m4_define([b4_table_value_equals], [[YYID (0)]], [[((]$2[) == (]$3[))]])]) + ## ---------## ## 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]) diff --git a/data/glr.c b/data/glr.c index 17eff387..89fbe101 100644 --- a/data/glr.c +++ b/data/glr.c @@ -171,6 +171,8 @@ m4_if(b4_prefix, [yy], [], /* Copy the first part of user declarations. */ ]b4_user_pre_prologue +b4_null_define + dnl # b4_shared_declarations dnl # ---------------------- dnl # Declaration that might either go into the header (if --defines) @@ -310,8 +312,7 @@ b4_percent_code_get[]dnl #ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ # if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) \ - || (defined __STRICT_ANSI__ && __STRICT_ANSI__)) + || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) # define __attribute__(Spec) /* empty */ # endif #endif @@ -827,7 +828,7 @@ static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg) static void yyFail (yyGLRStack* yystackp]b4_pure_formals[, const char* yymsg) { - if (yymsg != NULL) + if (yymsg != YY_NULL) yyerror (]b4_yyerror_args[yymsg); YYLONGJMP (yystackp->yyexception_buffer, 1); } @@ -901,7 +902,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, ]b4_user_formals[) { yybool yynormal __attribute__ ((__unused__)) = - (yystackp->yysplitPoint == NULL); + (yystackp->yysplitPoint == YY_NULL); int yylow; ]b4_parse_param_use[]dnl [# undef yyerrok @@ -988,7 +989,7 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[) else YYFPRINTF (stderr, "%s incomplete ", yymsg); 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"); } #endif @@ -1141,7 +1142,7 @@ yyinitStateSet (yyGLRStateSet* yyset) yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]); if (! yyset->yystates) return yyfalse; - yyset->yystates[0] = NULL; + yyset->yystates[0] = YY_NULL; yyset->yylookaheadNeeds = (yybool*) YYMALLOC (16 * sizeof yyset->yylookaheadNeeds[0]); if (! yyset->yylookaheadNeeds) @@ -1171,8 +1172,8 @@ yyinitGLRStack (yyGLRStack* yystackp, size_t yysize) if (!yystackp->yyitems) return yyfalse; yystackp->yynextFree = yystackp->yyitems; - yystackp->yysplitPoint = NULL; - yystackp->yylastDeleted = NULL; + yystackp->yysplitPoint = YY_NULL; + yystackp->yylastDeleted = YY_NULL; return yyinitStateSet (&yystackp->yytops); } @@ -1211,10 +1212,10 @@ yyexpandGLRStack (yyGLRStack* yystackp) { yyGLRState* yys0 = &yyp0->yystate; yyGLRState* yys1 = &yyp1->yystate; - if (yys0->yypred != NULL) + if (yys0->yypred != YY_NULL) yys1->yypred = YYRELOC (yyp0, yyp1, yys0->yypred, yystate); - if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != NULL) + if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != YY_NULL) yys1->yysemantics.yyfirstVal = YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption); } @@ -1222,18 +1223,18 @@ yyexpandGLRStack (yyGLRStack* yystackp) { yySemanticOption* yyv0 = &yyp0->yyoption; yySemanticOption* yyv1 = &yyp1->yyoption; - if (yyv0->yystate != NULL) + if (yyv0->yystate != YY_NULL) 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); } } - if (yystackp->yysplitPoint != NULL) + if (yystackp->yysplitPoint != YY_NULL) yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems, yystackp->yysplitPoint, yystate); 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] = YYRELOC (yystackp->yyitems, yynewItems, yystackp->yytops.yystates[yyn], yystate); @@ -1257,7 +1258,7 @@ yyfreeGLRStack (yyGLRStack* yystackp) static inline void yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys) { - if (yystackp->yysplitPoint != NULL && yystackp->yysplitPoint > yys) + if (yystackp->yysplitPoint != YY_NULL && yystackp->yysplitPoint > yys) yystackp->yysplitPoint = yys; } @@ -1265,9 +1266,9 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys) static inline void 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->yytops.yystates[yyk] = NULL; + yystackp->yytops.yystates[yyk] = YY_NULL; } /** Undelete the last stack that was marked as deleted. Can only be @@ -1276,12 +1277,12 @@ yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk) static void yyundeleteLastStack (yyGLRStack* yystackp) { - if (yystackp->yylastDeleted == NULL || yystackp->yytops.yysize != 0) + if (yystackp->yylastDeleted == YY_NULL || yystackp->yytops.yysize != 0) return; yystackp->yytops.yystates[0] = yystackp->yylastDeleted; yystackp->yytops.yysize = 1; YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n")); - yystackp->yylastDeleted = NULL; + yystackp->yylastDeleted = YY_NULL; } static inline void @@ -1291,7 +1292,7 @@ yyremoveDeletes (yyGLRStack* yystackp) yyi = yyj = 0; while (yyj < yystackp->yytops.yysize) { - if (yystackp->yytops.yystates[yyi] == NULL) + if (yystackp->yytops.yystates[yyi] == YY_NULL) { if (yyi == yyj) { @@ -1353,7 +1354,7 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, yynewState->yyposn = yyposn; yynewState->yyresolved = yyfalse; yynewState->yypred = yystackp->yytops.yystates[yyk]; - yynewState->yysemantics.yyfirstVal = NULL; + yynewState->yysemantics.yyfirstVal = YY_NULL; yystackp->yytops.yystates[yyk] = yynewState; /* Invokes YY_RESERVE_GLRSTACK. */ @@ -1372,7 +1373,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, { int yynrhs = yyrhsLength (yyrule); - if (yystackp->yysplitPoint == NULL) + if (yystackp->yysplitPoint == YY_NULL) { /* Standard special case: single stack. */ 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); yybool yynormal __attribute__ ((__unused__)) = - (yystackp->yysplitPoint == NULL); + (yystackp->yysplitPoint == YY_NULL); yyGLRStackItem* yyvsp = (yyGLRStackItem*) yystackp->yytops.yystates[yyk]; int yylow = 1; int yyi; @@ -1468,7 +1469,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, { size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn; - if (yyforceEval || yystackp->yysplitPoint == NULL) + if (yyforceEval || yystackp->yysplitPoint == YY_NULL) { YYSTYPE yysval; 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", (unsigned long int) yyk, yyrule - 1, yynewLRState)); 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; yyp = yystackp->yytops.yystates[yyi]; @@ -1528,7 +1529,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, static size_t yysplitStack (yyGLRStack* yystackp, size_t yyk) { - if (yystackp->yysplitPoint == NULL) + if (yystackp->yysplitPoint == YY_NULL) { YYASSERT (yyk == 0); yystackp->yysplitPoint = yystackp->yytops.yystates[yyk]; @@ -1538,7 +1539,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk) yyGLRState** yynewStates; yybool* yynewLookaheadNeeds; - yynewStates = NULL; + yynewStates = YY_NULL; if (yystackp->yytops.yycapacity > (YYSIZEMAX / (2 * sizeof yynewStates[0]))) @@ -1549,7 +1550,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk) (yyGLRState**) YYREALLOC (yystackp->yytops.yystates, (yystackp->yytops.yycapacity * sizeof yynewStates[0])); - if (yynewStates == NULL) + if (yynewStates == YY_NULL) yyMemoryExhausted (yystackp); yystackp->yytops.yystates = yynewStates; @@ -1557,7 +1558,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk) (yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds, (yystackp->yytops.yycapacity * sizeof yynewLookaheadNeeds[0])); - if (yynewLookaheadNeeds == NULL) + if (yynewLookaheadNeeds == YY_NULL) yyMemoryExhausted (yystackp); yystackp->yytops.yylookaheadNeeds = yynewLookaheadNeeds; } @@ -1623,9 +1624,9 @@ yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1) yyz1 = yys1->yysemantics.yyfirstVal; while (YYID (yytrue)) { - if (yyz1 == *yyz0p || yyz1 == NULL) + if (yyz1 == *yyz0p || yyz1 == YY_NULL) break; - else if (*yyz0p == NULL) + else if (*yyz0p == YY_NULL) { *yyz0p = yyz1; break; @@ -1748,7 +1749,7 @@ yyreportTree (yySemanticOption* yyx, int yyindent) for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred) yystates[yyi] = yys; - if (yys == NULL) + if (yys == YY_NULL) { yyleftmost_state.yyposn = 0; yystates[0] = &yyleftmost_state; @@ -1823,7 +1824,7 @@ yyresolveLocations (yyGLRState* yys1, int yyn1, YYSTYPE yylval_current; YYLTYPE yylloc_current; yyoption = yys1->yysemantics.yyfirstVal; - YYASSERT (yyoption != NULL); + YYASSERT (yyoption != YY_NULL); yynrhs = yyrhsLength (yyoption->yyrule); if (yynrhs > 0) { @@ -1881,7 +1882,7 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[) yybest = yyoptionList; yymerge = yyfalse; - for (yypp = &yyoptionList->yynext; *yypp != NULL; ) + for (yypp = &yyoptionList->yynext; *yypp != YY_NULL; ) { yySemanticOption* yyp = *yypp; @@ -1924,7 +1925,7 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[) yyflag = yyresolveAction (yybest, yystackp, &yysval, yylocp]b4_user_args[); 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]) { @@ -1952,14 +1953,14 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[) yys->yysemantics.yysval = yysval; } else - yys->yysemantics.yyfirstVal = NULL; + yys->yysemantics.yyfirstVal = YY_NULL; return yyflag; } static YYRESULTTAG yyresolveStack (yyGLRStack* yystackp]b4_user_formals[) { - if (yystackp->yysplitPoint != NULL) + if (yystackp->yysplitPoint != YY_NULL) { yyGLRState* yys; int yyn; @@ -1979,10 +1980,10 @@ yycompressStack (yyGLRStack* yystackp) { yyGLRState* yyp, *yyq, *yyr; - if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == NULL) + if (yystackp->yytops.yysize != 1 || yystackp->yysplitPoint == YY_NULL) 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; yyr = yyp, yyp = yyq, yyq = yyp->yypred) yyp->yypred = yyr; @@ -1990,10 +1991,10 @@ yycompressStack (yyGLRStack* yystackp) yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems; yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1; yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems; - yystackp->yysplitPoint = NULL; - yystackp->yylastDeleted = NULL; + yystackp->yysplitPoint = YY_NULL; + yystackp->yylastDeleted = YY_NULL; - while (yyr != NULL) + while (yyr != YY_NULL) { yystackp->yynextFree->yystate = *yyr; yyr = yyr->yypred; @@ -2012,7 +2013,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk, const short int* yyconflicts; yyRuleNum yyrule; - while (yystackp->yytops.yystates[yyk] != NULL) + while (yystackp->yytops.yystates[yyk] != YY_NULL) { yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState; 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")); #else 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 yysize1; yybool yysize_overflow = yyfalse; - char* yymsg = NULL; + char* yymsg = YY_NULL; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = 0; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -2156,7 +2157,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) break; } yyarg[yycount++] = yytokenName (yyx); - yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx)); + yysize1 = yysize + yytnamerr (YY_NULL, yytokenName (yyx)); yysize_overflow |= yysize1 < yysize; yysize = yysize1; } @@ -2230,7 +2231,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) { yySymbol yytoken; if (yychar == YYEOF) - yyFail (yystackp][]b4_lpure_args[, NULL); + yyFail (yystackp][]b4_lpure_args[, YY_NULL); if (yychar != YYEMPTY) {]b4_locations_if([[ /* We throw away the lookahead, but the error range @@ -2271,10 +2272,10 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) /* Reduce to one stack. */ for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1) - if (yystackp->yytops.yystates[yyk] != NULL) + if (yystackp->yytops.yystates[yyk] != YY_NULL) break; 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) yymarkStackDeleted (yystackp, yyk); 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. */ yystackp->yyerrState = 3; - while (yystackp->yytops.yystates[0] != NULL) + while (yystackp->yytops.yystates[0] != YY_NULL) { yyGLRState *yys = yystackp->yytops.yystates[0]; 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;]])[ - if (yys->yypred != NULL) + if (yys->yypred != YY_NULL) yydestroyGLRState ("Error: popping", yys]b4_user_args[); yystackp->yytops.yystates[0] = yys->yypred; yystackp->yynextFree -= 1; yystackp->yyspaceLeft += 1; } - if (yystackp->yytops.yystates[0] == NULL) - yyFail (yystackp][]b4_lpure_args[, NULL); + if (yystackp->yytops.yystates[0] == YY_NULL) + yyFail (yystackp][]b4_lpure_args[, YY_NULL); } #define YYCHK1(YYE) \ @@ -2564,7 +2565,7 @@ m4_popdef([b4_at_dollar])])dnl { yyGLRState *yys = yystates[yyk]; ]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[); yystates[yyk] = yys->yypred; yystack.yynextFree -= 1; @@ -2601,7 +2602,7 @@ yy_yypstack (yyGLRState* yys) static void yypstates (yyGLRState* yyst) { - if (yyst == NULL) + if (yyst == YY_NULL) YYFPRINTF (stderr, ""); else yy_yypstack (yyst); @@ -2615,7 +2616,7 @@ yypstack (yyGLRStack* yystackp, size_t yyk) } #define YYINDEX(YYX) \ - ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems) + ((YYX) == YY_NULL ? -1 : (yyGLRStackItem*) (YYX) - yystackp->yyitems) static void diff --git a/data/lalr1.cc b/data/lalr1.cc index 6f55e187..dc0cc8cc 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -51,6 +51,8 @@ dnl FIXME: This is wrong, we want computed header guards. ]b4_percent_define_ifdef([[location_type]], [], [[#include "location.hh"]])[ +]b4_null_define[ + /* Enabling traces. */ #ifndef YYDEBUG # 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) { #define YYCASE_(N, S) \ diff --git a/data/location.cc b/data/location.cc index d264d275..f4fc9cc5 100644 --- a/data/location.cc +++ b/data/location.cc @@ -20,7 +20,7 @@ m4_changecom() m4_divert_push(0)dnl @output(b4_dir_prefix[]position.hh@)@ b4_copyright([Positions for Bison parsers in C++], - [2002-2007, 2009-2011])[ + [2002-2007, 2009-2012])[ /** ** \file position.hh @@ -34,6 +34,8 @@ b4_copyright([Positions for Bison parsers in C++], # include # include +]b4_null_define[ + ]b4_namespace_open[ /// Abstract a position. class position @@ -42,13 +44,13 @@ b4_copyright([Positions for Bison parsers in C++], ]m4_ifdef([b4_location_constructors], [ /// Construct a 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. - inline void initialize (]b4_percent_define_get([[filename_type]])[* fn) + inline void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULL) { filename = fn; line = ]b4_location_initial_line[; @@ -174,7 +176,7 @@ b4_copyright([Locations for Bison parsers in C++], ])[ /// 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); end = begin; diff --git a/data/yacc.c b/data/yacc.c index 96eea2a8..8d26479d 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -267,6 +267,8 @@ m4_if(b4_prefix, [yy], [], /* Copy the first part of user declarations. */ ]b4_user_pre_prologue[ +]b4_null_define[ + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG ]b4_debug_flag[ diff --git a/lib/libiberty.h b/lib/libiberty.h index fdcae40b..ad7b358f 100644 --- a/lib/libiberty.h +++ b/lib/libiberty.h @@ -24,7 +24,7 @@ # define BISON_LIBIBERTY_H_ 1 # ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) # define __attribute__(x) # endif # endif diff --git a/src/system.h b/src/system.h index e3f17d89..d3c544b4 100644 --- a/src/system.h +++ b/src/system.h @@ -85,7 +85,7 @@ typedef size_t uintptr_t; # ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ # if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__) + || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) # define __attribute__(Spec) /* empty */ # endif # endif diff --git a/tests/actions.at b/tests/actions.at index ed913cd1..bb2201db 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -345,7 +345,7 @@ thing: ; %% /* Alias to ARGV[1]. */ -const char *source = 0; +const char *source = YY_NULL; static int yylex (]AT_LEX_FORMALS[) diff --git a/tests/calc.at b/tests/calc.at index 455cd72f..c5040083 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -241,7 +241,7 @@ int yylex (]AT_LEX_FORMALS[); are stored in a union, from which objects with constructors are excluded in C++. */ %initial-action { - @$.initialize (0); + @$.initialize (); } ])])[ diff --git a/tests/regression.at b/tests/regression.at index 90ea6497..584c541b 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -769,7 +769,7 @@ static const yytype_uint8 yyrline[] = static const char *const yytname[] = { "$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[] = {