glr.c: beware of portability issues with PTRDIFF_MAX

For instance test 386, "glr.cc api.value.type={double}":

    types.at:366: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o test test.cc $LIBS
    stderr:
    test.cc: In function 'ptrdiff_t yysplitStack(yyGLRStack*, ptrdiff_t)':
    test.cc:490:4: error: 'PTRDIFF_MAX' was not declared in this scope
       (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : YY_CAST (ptrdiff_t, SIZE_MAX))
        ^
    test.cc:1805:37: note: in expansion of macro 'YYSIZEMAX'
           ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size;
                                         ^~~~~~~~~
    test.cc:490:4: note: suggested alternative: '__PTRDIFF_MAX__'
       (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : YY_CAST (ptrdiff_t, SIZE_MAX))
        ^
    test.cc:1805:37: note: in expansion of macro 'YYSIZEMAX'
           ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size;
                                         ^~~~~~~~~

The failing tests are using glr.cc only, which I don't understand, the
problem is rather in glr.c, so I would expect glr.c tests to also fail.

Reported by Bruno Haible.
https://lists.gnu.org/archive/html/bug-bison/2020-05/msg00053.html

* data/skeletons/yacc.c: Move the block that defines
YYPTRDIFF_T/YYPTRDIFF_MAXIMUM, YYSIZE_T/YYSIZE_MAXIMUM, and
YYSIZEOF to...
* data/skeletons/c.m4 (b4_sizes_types_define): Here.
(b4_c99_int_type): Also take care of the #undefinition of short.
* data/skeletons/yacc.c, data/skeletons/glr.c: Use
b4_sizes_types_define.
* data/skeletons/glr.c: Adjust to use YYPTRDIFF_T/YYPTRDIFF_MAXIMUM,
YYSIZE_T/YYSIZE_MAXIMUM.
This commit is contained in:
Akim Demaille
2020-05-04 07:37:49 +02:00
parent 7727693711
commit 4b85b969d0
5 changed files with 105 additions and 98 deletions

View File

@@ -205,7 +205,11 @@ m4_define([b4_c99_int_type],
# Define private types suitable for holding small integers in C99 or later. # Define private types suitable for holding small integers in C99 or later.
m4_define([b4_c99_int_type_define], m4_define([b4_c99_int_type_define],
[m4_copy_force([b4_c99_int_type], [b4_int_type])dnl [m4_copy_force([b4_c99_int_type], [b4_int_type])dnl
[/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure [#ifdef short
# undef short
#endif
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
<limits.h> and (if available) <stdint.h> are included <limits.h> and (if available) <stdint.h> are included
so that the code can choose integer types of a good width. */ so that the code can choose integer types of a good width. */
@@ -261,6 +265,50 @@ typedef int yytype_uint16;
#endif]]) #endif]])
# b4_sizes_types_define
# ---------------------
# Define YYPTRDIFF_T/YYPTRDIFF_MAXIMUM, YYSIZE_T/YYSIZE_MAXIMUM,
# and YYSIZEOF.
m4_define([b4_sizes_types_define],
[[#ifndef YYPTRDIFF_T
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
# define YYPTRDIFF_T __PTRDIFF_TYPE__
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
# elif defined PTRDIFF_MAX
# ifndef ptrdiff_t
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# endif
# define YYPTRDIFF_T ptrdiff_t
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
# else
# define YYPTRDIFF_T long
# define YYPTRDIFF_MAXIMUM LONG_MAX
# endif
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned
# endif
#endif
#define YYSIZE_MAXIMUM \
YY_CAST (YYPTRDIFF_T, \
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
? YYPTRDIFF_MAXIMUM \
: YY_CAST (YYSIZE_T, -1)))
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
]])
# b4_int_type_for(NAME) # b4_int_type_for(NAME)
# --------------------- # ---------------------
# Return a narrow int type able to handle numbers ranging from # Return a narrow int type able to handle numbers ranging from

View File

@@ -249,6 +249,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
#include <string.h> #include <string.h>
]b4_c99_int_type_define[ ]b4_c99_int_type_define[
]b4_sizes_types_define[
#ifndef YY_ #ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS # if defined YYENABLE_NLS && YYENABLE_NLS
@@ -277,9 +278,6 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
# define YYREALLOC realloc # define YYREALLOC realloc
#endif #endif
#define YYSIZEMAX \
(PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : YY_CAST (ptrdiff_t, SIZE_MAX))
#ifdef __cplusplus #ifdef __cplusplus
typedef bool yybool; typedef bool yybool;
# define yytrue true # define yytrue true
@@ -507,7 +505,7 @@ struct yyGLRState {
/** Preceding state in this stack */ /** Preceding state in this stack */
yyGLRState* yypred; yyGLRState* yypred;
/** Source position of the last token produced by my symbol */ /** Source position of the last token produced by my symbol */
ptrdiff_t yyposn; YYPTRDIFF_T yyposn;
union { union {
/** First in a chain of alternative reductions producing the /** First in a chain of alternative reductions producing the
* nonterminal corresponding to this state, threaded through * nonterminal corresponding to this state, threaded through
@@ -527,8 +525,8 @@ struct yyGLRStateSet {
* operation, yylookaheadNeeds[0] is not maintained since it would merely * operation, yylookaheadNeeds[0] is not maintained since it would merely
* duplicate yychar != ]b4_symbol(-2, id)[. */ * duplicate yychar != ]b4_symbol(-2, id)[. */
yybool* yylookaheadNeeds; yybool* yylookaheadNeeds;
ptrdiff_t yysize; YYPTRDIFF_T yysize;
ptrdiff_t yycapacity; YYPTRDIFF_T yycapacity;
}; };
struct yySemanticOption { struct yySemanticOption {
@@ -568,7 +566,7 @@ struct yyGLRStack {
YYJMP_BUF yyexception_buffer; YYJMP_BUF yyexception_buffer;
yyGLRStackItem* yyitems; yyGLRStackItem* yyitems;
yyGLRStackItem* yynextFree; yyGLRStackItem* yynextFree;
ptrdiff_t yyspaceLeft; YYPTRDIFF_T yyspaceLeft;
yyGLRState* yysplitPoint; yyGLRState* yysplitPoint;
yyGLRState* yylastDeleted; yyGLRState* yylastDeleted;
yyGLRStateSet yytops; yyGLRStateSet yytops;
@@ -680,7 +678,7 @@ yysymbol_name (yysymbol_kind_t yysymbol)
multiple parsers can coexist. */ multiple parsers can coexist. */
int yydebug; int yydebug;
static void yypstack (yyGLRStack* yystackp, ptrdiff_t yyk) static void yypstack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
YY_ATTRIBUTE_UNUSED; YY_ATTRIBUTE_UNUSED;
static void yypdumpstack (yyGLRStack* yystackp) static void yypdumpstack (yyGLRStack* yystackp)
YY_ATTRIBUTE_UNUSED; YY_ATTRIBUTE_UNUSED;
@@ -696,7 +694,7 @@ static void yypdumpstack (yyGLRStack* yystackp)
[simple], [simple],
[[]], [[]],
[[#ifndef yystrlen [[#ifndef yystrlen
# define yystrlen(S) (YY_CAST (ptrdiff_t, strlen (S))) # define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
#endif #endif
]b4_parse_error_bmatch( ]b4_parse_error_bmatch(
@@ -731,12 +729,12 @@ yystpcpy (char *yydest, const char *yysrc)
backslash-backslash). YYSTR is taken from yytname. If YYRES is backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result null, do not copy; instead, return the length of what the result
would have been. */ would have been. */
static ptrdiff_t static YYPTRDIFF_T
yytnamerr (char *yyres, const char *yystr) yytnamerr (char *yyres, const char *yystr)
{ {
if (*yystr == '"') if (*yystr == '"')
{ {
ptrdiff_t yyn = 0; YYPTRDIFF_T yyn = 0;
char const *yyp = yystr; char const *yyp = yystr;
for (;;) for (;;)
@@ -1104,7 +1102,7 @@ yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
* alternative actions for YYSTATE. Assumes that YYRHS comes from * alternative actions for YYSTATE. Assumes that YYRHS comes from
* stack #YYK of *YYSTACKP. */ * stack #YYK of *YYSTACKP. */
static void static void
yyaddDeferredAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyGLRState* yystate, yyaddDeferredAction (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyGLRState* yystate,
yyGLRState* yyrhs, yyRuleNum yyrule) yyGLRState* yyrhs, yyRuleNum yyrule)
{ {
yySemanticOption* yynewOption = yySemanticOption* yynewOption =
@@ -1136,14 +1134,14 @@ yyinitStateSet (yyGLRStateSet* yyset)
yyset->yycapacity = 16; yyset->yycapacity = 16;
yyset->yystates yyset->yystates
= YY_CAST (yyGLRState**, = YY_CAST (yyGLRState**,
YYMALLOC (YY_CAST (size_t, yyset->yycapacity) YYMALLOC (YY_CAST (YYSIZE_T, yyset->yycapacity)
* sizeof yyset->yystates[0])); * sizeof yyset->yystates[0]));
if (! yyset->yystates) if (! yyset->yystates)
return yyfalse; return yyfalse;
yyset->yystates[0] = YY_NULLPTR; yyset->yystates[0] = YY_NULLPTR;
yyset->yylookaheadNeeds yyset->yylookaheadNeeds
= YY_CAST (yybool*, = YY_CAST (yybool*,
YYMALLOC (YY_CAST (size_t, yyset->yycapacity) YYMALLOC (YY_CAST (YYSIZE_T, yyset->yycapacity)
* sizeof yyset->yylookaheadNeeds[0])); * sizeof yyset->yylookaheadNeeds[0]));
if (! yyset->yylookaheadNeeds) if (! yyset->yylookaheadNeeds)
{ {
@@ -1152,7 +1150,7 @@ yyinitStateSet (yyGLRStateSet* yyset)
} }
memset (yyset->yylookaheadNeeds, memset (yyset->yylookaheadNeeds,
0, 0,
YY_CAST (size_t, yyset->yycapacity) * sizeof yyset->yylookaheadNeeds[0]); YY_CAST (YYSIZE_T, yyset->yycapacity) * sizeof yyset->yylookaheadNeeds[0]);
return yytrue; return yytrue;
} }
@@ -1165,14 +1163,14 @@ static void yyfreeStateSet (yyGLRStateSet* yyset)
/** Initialize *YYSTACKP to a single empty stack, with total maximum /** Initialize *YYSTACKP to a single empty stack, with total maximum
* capacity for all stacks of YYSIZE. */ * capacity for all stacks of YYSIZE. */
static yybool static yybool
yyinitGLRStack (yyGLRStack* yystackp, ptrdiff_t yysize) yyinitGLRStack (yyGLRStack* yystackp, YYPTRDIFF_T yysize)
{ {
yystackp->yyerrState = 0; yystackp->yyerrState = 0;
yynerrs = 0; yynerrs = 0;
yystackp->yyspaceLeft = yysize; yystackp->yyspaceLeft = yysize;
yystackp->yyitems yystackp->yyitems
= YY_CAST (yyGLRStackItem*, = YY_CAST (yyGLRStackItem*,
YYMALLOC (YY_CAST (size_t, yysize) YYMALLOC (YY_CAST (YYSIZE_T, yysize)
* sizeof yystackp->yynextFree[0])); * sizeof yystackp->yynextFree[0]));
if (!yystackp->yyitems) if (!yystackp->yyitems)
return yyfalse; return yyfalse;
@@ -1198,9 +1196,9 @@ yyexpandGLRStack (yyGLRStack* yystackp)
{ {
yyGLRStackItem* yynewItems; yyGLRStackItem* yynewItems;
yyGLRStackItem* yyp0, *yyp1; yyGLRStackItem* yyp0, *yyp1;
ptrdiff_t yynewSize; YYPTRDIFF_T yynewSize;
ptrdiff_t yyn; YYPTRDIFF_T yyn;
ptrdiff_t yysize = yystackp->yynextFree - yystackp->yyitems; YYPTRDIFF_T yysize = yystackp->yynextFree - yystackp->yyitems;
if (YYMAXDEPTH - YYHEADROOM < yysize) if (YYMAXDEPTH - YYHEADROOM < yysize)
yyMemoryExhausted (yystackp); yyMemoryExhausted (yystackp);
yynewSize = 2*yysize; yynewSize = 2*yysize;
@@ -1208,7 +1206,7 @@ yyexpandGLRStack (yyGLRStack* yystackp)
yynewSize = YYMAXDEPTH; yynewSize = YYMAXDEPTH;
yynewItems yynewItems
= YY_CAST (yyGLRStackItem*, = YY_CAST (yyGLRStackItem*,
YYMALLOC (YY_CAST (size_t, yynewSize) YYMALLOC (YY_CAST (YYSIZE_T, yynewSize)
* sizeof yynewItems[0])); * sizeof yynewItems[0]));
if (! yynewItems) if (! yynewItems)
yyMemoryExhausted (yystackp); yyMemoryExhausted (yystackp);
@@ -1273,7 +1271,7 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
/** Invalidate stack #YYK in *YYSTACKP. */ /** Invalidate stack #YYK in *YYSTACKP. */
static inline void static inline void
yymarkStackDeleted (yyGLRStack* yystackp, ptrdiff_t yyk) yymarkStackDeleted (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
{ {
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR) if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
yystackp->yylastDeleted = yystackp->yytops.yystates[yyk]; yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
@@ -1297,7 +1295,7 @@ yyundeleteLastStack (yyGLRStack* yystackp)
static inline void static inline void
yyremoveDeletes (yyGLRStack* yystackp) yyremoveDeletes (yyGLRStack* yystackp)
{ {
ptrdiff_t yyi, yyj; YYPTRDIFF_T yyi, yyj;
yyi = yyj = 0; yyi = yyj = 0;
while (yyj < yystackp->yytops.yysize) while (yyj < yystackp->yytops.yysize)
{ {
@@ -1330,8 +1328,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
* state YYLRSTATE, at input position YYPOSN, with (resolved) semantic * state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
* value *YYVALP and source location *YYLOCP. */ * value *YYVALP and source location *YYLOCP. */
static inline void static inline void
yyglrShift (yyGLRStack* yystackp, ptrdiff_t yyk, yy_state_t yylrState, yyglrShift (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yy_state_t yylrState,
ptrdiff_t yyposn, YYPTRDIFF_T yyposn,
YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[) YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
{ {
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate; yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
@@ -1351,8 +1349,8 @@ yyglrShift (yyGLRStack* yystackp, ptrdiff_t yyk, yy_state_t yylrState,
* state YYLRSTATE, at input position YYPOSN, with the (unresolved) * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
* semantic value of YYRHS under the action for YYRULE. */ * semantic value of YYRHS under the action for YYRULE. */
static inline void static inline void
yyglrShiftDefer (yyGLRStack* yystackp, ptrdiff_t yyk, yy_state_t yylrState, yyglrShiftDefer (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yy_state_t yylrState,
ptrdiff_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule) YYPTRDIFF_T yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
{ {
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate; yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
YY_ASSERT (yynewState->yyisState); YY_ASSERT (yynewState->yyisState);
@@ -1382,7 +1380,7 @@ yyglrShiftDefer (yyGLRStack* yystackp, ptrdiff_t yyk, yy_state_t yylrState,
`----------------------------------------------------------------------*/ `----------------------------------------------------------------------*/
static inline void static inline void
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk, yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, YYPTRDIFF_T yyk,
yyRuleNum yyrule]b4_user_formals[) yyRuleNum yyrule]b4_user_formals[)
{ {
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([ int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
@@ -1415,7 +1413,7 @@ yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk,
* and *YYLOCP to the computed location (if any). Return value is as * and *YYLOCP to the computed location (if any). Return value is as
* for userAction. */ * for userAction. */
static inline YYRESULTTAG static inline YYRESULTTAG
yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule, yydoAction (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyRuleNum yyrule,
YYSTYPE* yyvalp]b4_locuser_formals[) YYSTYPE* yyvalp]b4_locuser_formals[)
{ {
int yynrhs = yyrhsLength (yyrule); int yynrhs = yyrhsLength (yyrule);
@@ -1467,10 +1465,10 @@ yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
* added to the options for the existing state's semantic value. * added to the options for the existing state's semantic value.
*/ */
static inline YYRESULTTAG static inline YYRESULTTAG
yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule, yyglrReduce (yyGLRStack* yystackp, YYPTRDIFF_T yyk, yyRuleNum yyrule,
yybool yyforceEval]b4_user_formals[) yybool yyforceEval]b4_user_formals[)
{ {
ptrdiff_t yyposn = yystackp->yytops.yystates[yyk]->yyposn; YYPTRDIFF_T yyposn = yystackp->yytops.yystates[yyk]->yyposn;
if (yyforceEval || yystackp->yysplitPoint == YY_NULLPTR) if (yyforceEval || yystackp->yysplitPoint == YY_NULLPTR)
{ {
@@ -1492,7 +1490,7 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
} }
else else
{ {
ptrdiff_t yyi; YYPTRDIFF_T yyi;
int yyn; int yyn;
yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk]; yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
yy_state_t yynewLRState; yy_state_t yynewLRState;
@@ -1534,8 +1532,8 @@ yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
return yyok; return yyok;
} }
static ptrdiff_t static YYPTRDIFF_T
yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk) yysplitStack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
{ {
if (yystackp->yysplitPoint == YY_NULLPTR) if (yystackp->yysplitPoint == YY_NULLPTR)
{ {
@@ -1544,8 +1542,8 @@ yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
} }
if (yystackp->yytops.yycapacity <= yystackp->yytops.yysize) if (yystackp->yytops.yycapacity <= yystackp->yytops.yysize)
{ {
ptrdiff_t state_size = sizeof yystackp->yytops.yystates[0]; YYPTRDIFF_T state_size = YYSIZEOF (yystackp->yytops.yystates[0]);
ptrdiff_t half_max_capacity = YYSIZEMAX / 2 / state_size; YYPTRDIFF_T half_max_capacity = YYSIZE_MAXIMUM / 2 / state_size;
if (half_max_capacity < yystackp->yytops.yycapacity) if (half_max_capacity < yystackp->yytops.yycapacity)
yyMemoryExhausted (yystackp); yyMemoryExhausted (yystackp);
yystackp->yytops.yycapacity *= 2; yystackp->yytops.yycapacity *= 2;
@@ -1554,7 +1552,7 @@ yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
yyGLRState** yynewStates yyGLRState** yynewStates
= YY_CAST (yyGLRState**, = YY_CAST (yyGLRState**,
YYREALLOC (yystackp->yytops.yystates, YYREALLOC (yystackp->yytops.yystates,
(YY_CAST (size_t, yystackp->yytops.yycapacity) (YY_CAST (YYSIZE_T, yystackp->yytops.yycapacity)
* sizeof yynewStates[0]))); * sizeof yynewStates[0])));
if (yynewStates == YY_NULLPTR) if (yynewStates == YY_NULLPTR)
yyMemoryExhausted (yystackp); yyMemoryExhausted (yystackp);
@@ -1565,7 +1563,7 @@ yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
yybool* yynewLookaheadNeeds yybool* yynewLookaheadNeeds
= YY_CAST (yybool*, = YY_CAST (yybool*,
YYREALLOC (yystackp->yytops.yylookaheadNeeds, YYREALLOC (yystackp->yytops.yylookaheadNeeds,
(YY_CAST (size_t, yystackp->yytops.yycapacity) (YY_CAST (YYSIZE_T, yystackp->yytops.yycapacity)
* sizeof yynewLookaheadNeeds[0]))); * sizeof yynewLookaheadNeeds[0])));
if (yynewLookaheadNeeds == YY_NULLPTR) if (yynewLookaheadNeeds == YY_NULLPTR)
yyMemoryExhausted (yystackp); yyMemoryExhausted (yystackp);
@@ -1996,8 +1994,8 @@ yycompressStack (yyGLRStack* yystackp)
} }
static YYRESULTTAG static YYRESULTTAG
yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk, yyprocessOneStack (yyGLRStack* yystackp, YYPTRDIFF_T yyk,
ptrdiff_t yyposn]b4_pure_formals[) YYPTRDIFF_T yyposn]b4_pure_formals[)
{ {
while (yystackp->yytops.yystates[yyk] != YY_NULLPTR) while (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
{ {
@@ -2040,7 +2038,7 @@ yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
for (/* nothing */; *yyconflicts; yyconflicts += 1) for (/* nothing */; *yyconflicts; yyconflicts += 1)
{ {
YYRESULTTAG yyflag; YYRESULTTAG yyflag;
ptrdiff_t yynewStack = yysplitStack (yystackp, yyk); YYPTRDIFF_T yynewStack = yysplitStack (yystackp, yyk);
YY_DPRINTF ((stderr, "Splitting off stack %ld from %ld.\n", YY_DPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
YY_CAST (long, yynewStack), YY_CAST (long, yyk))); YY_CAST (long, yynewStack), YY_CAST (long, yyk)));
yyflag = yyglrReduce (yystackp, yynewStack, yyflag = yyglrReduce (yystackp, yynewStack,
@@ -2228,7 +2226,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
one per "expected"). */ one per "expected"). */
yysymbol_kind_t yyarg[YYARGS_MAX]; yysymbol_kind_t yyarg[YYARGS_MAX];
/* Cumulated lengths of YYARG. */ /* Cumulated lengths of YYARG. */
ptrdiff_t yysize = 0; YYPTRDIFF_T yysize = 0;
/* Actual size of YYARG. */ /* Actual size of YYARG. */
int yycount int yycount
@@ -2259,11 +2257,11 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
int yyi; int yyi;
for (yyi = 0; yyi < yycount; ++yyi) for (yyi = 0; yyi < yycount; ++yyi)
{ {
ptrdiff_t yysz YYPTRDIFF_T yysz
= ]b4_parse_error_case( = ]b4_parse_error_case(
[verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]], [verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]],
[[yystrlen (yysymbol_name (yyarg[yyi]))]]);[ [[yystrlen (yysymbol_name (yyarg[yyi]))]]);[
if (YYSIZEMAX - yysize < yysz) if (YYSIZE_MAXIMUM - yysize < yysz)
yysize_overflow = yytrue; yysize_overflow = yytrue;
else else
yysize += yysz; yysize += yysz;
@@ -2271,7 +2269,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
} }
if (!yysize_overflow) if (!yysize_overflow)
yymsg = YY_CAST (char *, YYMALLOC (YY_CAST (size_t, yysize))); yymsg = YY_CAST (char *, YYMALLOC (YY_CAST (YYSIZE_T, yysize)));
if (yymsg) if (yymsg)
{ {
@@ -2348,7 +2346,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
/* Reduce to one stack. */ /* Reduce to one stack. */
{ {
ptrdiff_t yyk; YYPTRDIFF_T yyk;
for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1) for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR) if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
break; break;
@@ -2423,7 +2421,7 @@ yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
int yyresult; int yyresult;
yyGLRStack yystack; yyGLRStack yystack;
yyGLRStack* const yystackp = &yystack; yyGLRStack* const yystackp = &yystack;
ptrdiff_t yyposn; YYPTRDIFF_T yyposn;
YY_DPRINTF ((stderr, "Starting parse\n")); YY_DPRINTF ((stderr, "Starting parse\n"));
@@ -2505,7 +2503,7 @@ b4_dollar_popdef])[]dnl
while (yytrue) while (yytrue)
{ {
yysymbol_kind_t yytoken_to_shift; yysymbol_kind_t yytoken_to_shift;
ptrdiff_t yys; YYPTRDIFF_T yys;
for (yys = 0; yys < yystack.yytops.yysize; yys += 1) for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
yystackp->yytops.yylookaheadNeeds[yys] = yychar != ]b4_symbol(-2, id)[; yystackp->yytops.yylookaheadNeeds[yys] = yychar != ]b4_symbol(-2, id)[;
@@ -2612,8 +2610,8 @@ b4_dollar_popdef])[]dnl
yyGLRState** yystates = yystack.yytops.yystates; yyGLRState** yystates = yystack.yytops.yystates;
if (yystates) if (yystates)
{ {
ptrdiff_t yysize = yystack.yytops.yysize; YYPTRDIFF_T yysize = yystack.yytops.yysize;
ptrdiff_t yyk; YYPTRDIFF_T yyk;
for (yyk = 0; yyk < yysize; yyk += 1) for (yyk = 0; yyk < yysize; yyk += 1)
if (yystates[yyk]) if (yystates[yyk])
{ {
@@ -2660,7 +2658,7 @@ yypstates (yyGLRState* yyst)
} }
static void static void
yypstack (yyGLRStack* yystackp, ptrdiff_t yyk) yypstack (yyGLRStack* yystackp, YYPTRDIFF_T yyk)
{ {
yypstates (yystackp->yytops.yystates[yyk]); yypstates (yystackp->yytops.yystates[yyk]);
} }
@@ -2705,7 +2703,7 @@ yypdumpstack (yyGLRStack* yystackp)
YY_FPRINTF ((stderr, "Tops:")); YY_FPRINTF ((stderr, "Tops:"));
{ {
ptrdiff_t yyi; YYPTRDIFF_T yyi;
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1) for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
YY_FPRINTF ((stderr, "%ld: %ld; ", YY_CAST (long, yyi), YY_FPRINTF ((stderr, "%ld: %ld; ", YY_CAST (long, yyi),
YYINDEX (yystackp->yytops.yystates[yyi]))); YYINDEX (yystackp->yytops.yystates[yyi])));

View File

@@ -403,50 +403,10 @@ m4_if(b4_api_prefix, [yy], [],
]b4_declare_symbol_enum[ ]b4_declare_symbol_enum[
]b4_user_post_prologue[ ]b4_user_post_prologue[
]b4_percent_code_get[]dnl ]b4_percent_code_get[
[#ifdef short
# undef short
#endif
]b4_c99_int_type_define[ ]b4_c99_int_type_define[
#ifndef YYPTRDIFF_T ]b4_sizes_types_define[
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
# define YYPTRDIFF_T __PTRDIFF_TYPE__
# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
# elif defined PTRDIFF_MAX
# ifndef ptrdiff_t
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# endif
# define YYPTRDIFF_T ptrdiff_t
# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
# else
# define YYPTRDIFF_T long
# define YYPTRDIFF_MAXIMUM LONG_MAX
# endif
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned
# endif
#endif
#define YYSIZE_MAXIMUM \
YY_CAST (YYPTRDIFF_T, \
(YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
? YYPTRDIFF_MAXIMUM \
: YY_CAST (YYSIZE_T, -1)))
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
/* Stored state numbers (used for stacks). */ /* Stored state numbers (used for stacks). */
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t; typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t;

View File

@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.5.91. */ /* A Bison parser, made by GNU Bison 3.5.93. */
/* Bison implementation for Yacc-like parsers in C /* Bison implementation for Yacc-like parsers in C
@@ -49,7 +49,7 @@
#define YYBISON 1 #define YYBISON 1
/* Bison version. */ /* Bison version. */
#define YYBISON_VERSION "3.5.91" #define YYBISON_VERSION "3.5.93"
/* Skeleton name. */ /* Skeleton name. */
#define YYSKELETON_NAME "yacc.c" #define YYSKELETON_NAME "yacc.c"
@@ -408,6 +408,7 @@ typedef int yytype_uint16;
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
/* Stored state numbers (used for stacks). */ /* Stored state numbers (used for stacks). */
typedef yytype_uint8 yy_state_t; typedef yytype_uint8 yy_state_t;

View File

@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 3.5.91. */ /* A Bison parser, made by GNU Bison 3.5.93. */
/* Bison interface for Yacc-like parsers in C /* Bison interface for Yacc-like parsers in C