>From 5e167c50d77518d693f6165886788bdf323d3c13 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 1 Oct 2019 01:28:45 -0700 Subject: [PATCH] Prefer signed types for indexes in skeletons * NEWS: Mention this. * data/skeletons/c.m4 (b4_int_type): Prefer char if it will do, and prefer signed types to unsigned if either will do. * data/skeletons/glr.c (yy_reduce_print): No need to convert rule line to unsigned long. (yyrecoverSyntaxError): Put action into an int to avoid GCC warning of using a char subscript. * data/skeletons/lalr1.cc (yy_lac_check_, yysyntax_error_): Prefer ptrdiff_t to size_t. * data/skeletons/yacc.c (b4_int_type): Prefer signed types to unsigned if either will do. * data/skeletons/yacc.c (b4_declare_parser_state_variables): (YYSTACK_RELOCATE, YYCOPY, yy_lac_stack_realloc, yy_lac) (yytnamerr, yysyntax_error, yyparse): Prefer ptrdiff_t to size_t. (YYPTRDIFF_T, YYPTRDIFF_MAXIMUM): New macros. (YYSIZE_T): Fix "! defined YYSIZE_T" typo. (YYSIZE_MAXIMUM): Take the minimum of PTRDIFF_MAX and SIZE_MAX. (YYSIZEOF): New macro. (YYSTACK_GAP_MAXIMUM, YYSTACK_BYTES, YYSTACK_RELOCATE) (yy_lac_stack_realloc, yyparse): Use it. (YYCOPY, yy_lac_stack_realloc): Cast to YYSIZE_T to pacify GCC. (yy_reduce_print): Use int instead of unsigned long when int will do. (yy_lac_stack_realloc): Prefer long to unsigned long when either will do. * tests/regression.at: Adjust to these changes. --- NEWS | 6 ++ data/skeletons/c.m4 | 14 ++--- data/skeletons/glr.c | 11 ++-- data/skeletons/lalr1.cc | 20 +++---- data/skeletons/yacc.c | 127 ++++++++++++++++++++++++---------------- tests/regression.at | 16 ++--- 6 files changed, 112 insertions(+), 82 deletions(-) diff --git a/NEWS b/NEWS index 44929e35..e204a4b0 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,12 @@ GNU Bison NEWS The Java backend no longer emits code and data for parser tracing if the %define variable parse.trace is not defined. +*** Templates prefer signed integer types + + Bison templates now prefer signed to unsigned integer types when + either will do, as the signed types are less error-prone and allow + for better checking with 'gcc -fsanitize=undefined'. + * Noteworthy changes in release 3.4.2 (2019-09-12) [stable] ** Bug fixes diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index 27aa2939..bb12c880 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -167,16 +167,16 @@ b4_parse_param_for([Decl], [Formal], [ YYUSE (Formal); # b4_int_type(MIN, MAX) # --------------------- -# Return the smallest int type able to handle numbers ranging from -# MIN to MAX (included). +# Return a narrow int type able to handle integers ranging from MIN +# to MAX (included) in portable C code. Assume MIN and MAX fall in +# 'int' range. m4_define([b4_int_type], -[m4_if(b4_ints_in($@, [0], [255]), [1], [unsigned char], - b4_ints_in($@, [-128], [127]), [1], [signed char], +[m4_if(b4_ints_in($@, [0], [127]), [1], [char], + b4_ints_in($@, [-127], [127]), [1], [signed char], + b4_ints_in($@, [0], [255]), [1], [unsigned char], + b4_ints_in($@, [-32767], [32767]), [1], [short], b4_ints_in($@, [0], [65535]), [1], [unsigned short], - b4_ints_in($@, [-32768], [32767]), [1], [short], - - m4_eval([0 <= $1]), [1], [unsigned], [int])]) diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c index 9b088959..bce656e3 100644 --- a/data/skeletons/glr.c +++ b/data/skeletons/glr.c @@ -1343,9 +1343,9 @@ yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, size_t yyk, int yynrhs = yyrhsLength (yyrule);]b4_locations_if([ int yylow = 1;])[ int yyi; - YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %d):\n", (unsigned long) yyk, yyrule - 1, - (unsigned long) yyrline[yyrule]); + yyrline[yyrule]); if (! yynormal) yyfillin (yyvsp, 1, -yynrhs); /* The symbols being reduced. */ @@ -2253,14 +2253,15 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR && yyisShiftAction (yytable[yyj])) { - /* Shift the error token. */]b4_locations_if([[ + /* Shift the error token. */ + int yyaction = yytable[yyj];]b4_locations_if([[ /* First adjust its location.*/ YYLTYPE yyerrloc; yystackp->yyerror_range[2].yystate.yyloc = yylloc; YYLLOC_DEFAULT (yyerrloc, (yystackp->yyerror_range), 2);]])[ - YY_SYMBOL_PRINT ("Shifting", yystos[yytable[yyj]], + YY_SYMBOL_PRINT ("Shifting", yystos[yyaction], &yylval, &yyerrloc); - yyglrShift (yystackp, 0, yytable[yyj], + yyglrShift (yystackp, 0, yyaction, yys->yyposn, &yylval]b4_locations_if([, &yyerrloc])[); yys = yystackp->yytops.yystates[0]; break; diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc index 21e147a1..1ca124c3 100644 --- a/data/skeletons/lalr1.cc +++ b/data/skeletons/lalr1.cc @@ -1155,11 +1155,11 @@ b4_dollar_popdef])[]dnl #if ]b4_api_PREFIX[DEBUG YYCDEBUG << "LAC: checking lookahead " << yytname_[yytoken] << ':'; #endif - size_t lac_top = 0; + ptrdiff_t lac_top = 0; while (true) { state_type top_state = (yylac_stack_.empty () - ? yystack_[lac_top].state + ? yystack_[(size_t) lac_top].state : yylac_stack_.back ()); int yyrule = yypact_[top_state]; if (yy_pact_value_is_default_ (yyrule) @@ -1194,12 +1194,12 @@ b4_dollar_popdef])[]dnl YYCDEBUG << " R" << yyrule - 1; // Pop the corresponding number of values from the stack. { - size_t yylen = yyr2_[yyrule]; + ptrdiff_t yylen = yyr2_[yyrule]; // First pop from the LAC stack as many tokens as possible. - size_t lac_size = yylac_stack_.size (); + ptrdiff_t lac_size = (ptrdiff_t) yylac_stack_.size (); if (yylen < lac_size) { - yylac_stack_.resize (lac_size - yylen); + yylac_stack_.resize ((size_t) (lac_size - yylen)); yylen = 0; } else if (lac_size) @@ -1207,13 +1207,13 @@ b4_dollar_popdef])[]dnl yylac_stack_.clear (); yylen -= lac_size; } - // Only aftwerwards look at the main stack. + // Only afterwards look at the main stack. // We simulate popping elements by incrementing lac_top. lac_top += yylen; } // Keep top_state in sync with the updated stack. top_state = (yylac_stack_.empty () - ? yystack_[lac_top].state + ? yystack_[(size_t) lac_top].state : yylac_stack_.back ()); // Push the resulting state of the reduction. state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]); @@ -1292,7 +1292,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], {]b4_error_verbose_if([[ // Number of reported tokens (one for the "unexpected", one per // "expected"). - size_t yycount = 0; + ptrdiff_t yycount = 0; // Its maximum. enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; // Arguments of yyformat. @@ -1387,7 +1387,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], std::string yyres; // Argument number. - size_t yyi = 0; + ptrdiff_t yyi = 0; for (char const* yyp = yyformat; *yyp; ++yyp) if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) { @@ -1436,7 +1436,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla], void ]b4_parser_class[::yy_reduce_print_ (int yyrule) { - unsigned yylno = yyrline_[yyrule]; + int yylno = yyrline_[yyrule]; int yynrhs = yyr2_[yyrule]; // Print the symbols being reduced, and their result. *yycdebug_ << "Reducing stack by rule " << yyrule - 1 diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c index ea97ad46..f9fafb8b 100644 --- a/data/skeletons/yacc.c +++ b/data/skeletons/yacc.c @@ -112,18 +112,16 @@ m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])]) # b4_int_type(MIN, MAX) # --------------------- -# Return the smallest int type able to handle numbers ranging from +# Return a narrow int type able to handle numbers ranging from # MIN to MAX (included). Overwrite the version from c.m4, which # uses only C89 types, so that the user can override the shorter # types, and so that pre-C89 compilers are handled correctly. m4_define([b4_int_type], -[m4_if(b4_ints_in($@, [0], [255]), [1], [yytype_uint8], - b4_ints_in($@, [-128], [127]), [1], [yytype_int8], +[m4_if(b4_ints_in($@, [-127], [127]), [1], [yytype_int8], + b4_ints_in($@, [0], [255]), [1], [yytype_uint8], + b4_ints_in($@, [-32767], [32767]), [1], [yytype_int16], b4_ints_in($@, [0], [65535]), [1], [yytype_uint16], - b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16], - - m4_eval([0 <= $1]), [1], [unsigned], [int])]) @@ -234,11 +232,11 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[ /* The locations where the error started and ended. */ YYLTYPE yyerror_range[3];]])[ - YYSIZE_T yystacksize;]b4_lac_if([[ + YYPTRDIFF_T yystacksize;]b4_lac_if([[ yytype_int16 yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@}; yytype_int16 *yyes; - YYSIZE_T yyes_capacity;]])]) + YYPTRDIFF_T yyes_capacity;]])]) # _b4_declare_yyparse_push @@ -415,12 +413,31 @@ typedef YYTYPE_INT16 yytype_int16; typedef short yytype_int16; #endif +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined ptrdiff_t && defined PTRDIFF_MAX +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# elif 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YYPTRDIFF_T ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T int +# include /* INFRINGES ON USER NAME SPACE */ +# define YYPTRDIFF_MAXIMUM INT_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 YYSIZE_T +# elif 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -428,7 +445,10 @@ typedef short yytype_int16; # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM ((YYPTRDIFF_T) (YYPTRDIFF_MAXIMUM < (YYSIZE_T) -1 \ + ? YYPTRDIFF_MAXIMUM : (YYSIZE_T) -1)) + +#define YYSIZEOF(X) ((YYPTRDIFF_T) sizeof (X)) #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -537,16 +557,17 @@ union yyalloc }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ ]b4_locations_if( [# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + ((N) * (YYSIZEOF (yytype_int16) + YYSIZEOF (YYSTYPE) \ + + YYSIZEOF (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM)], [# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yytype_int16) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM)])[ # define YYCOPY_NEEDED 1 @@ -559,11 +580,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -575,12 +596,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, (YYSIZE_T) (Count) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -759,10 +780,10 @@ do { \ ])[[int yyrule], [yyrule]]m4_ifset([b4_parse_param], [, b4_parse_param]))[ { - unsigned long yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) @@ -821,7 +842,7 @@ int yydebug; using YYSTACK_FREE. Return 0 if successful or if no reallocation is required. Return 1 if memory is exhausted. */ static int -yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, +yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd, #if ]b4_api_PREFIX[DEBUG char const *yydebug_prefix, char const *yydebug_suffix, @@ -830,12 +851,11 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, yytype_int16 *yybottom_no_free, yytype_int16 **yytop, yytype_int16 *yytop_empty) { - YYSIZE_T yysize_old = - (YYSIZE_T) (*yytop == yytop_empty ? 0 : *yytop - *yybottom + 1); - YYSIZE_T yysize_new = yysize_old + yyadd; + YYPTRDIFF_T yysize_old = *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1; + YYPTRDIFF_T yysize_new = yysize_old + yyadd; if (*yycapacity < yysize_new) { - YYSIZE_T yyalloc = 2 * yysize_new; + YYPTRDIFF_T yyalloc = 2 * yysize_new; yytype_int16 *yybottom_new; /* Use YYMAXDEPTH for maximum stack size given that the stack should never need to grow larger than the main state stack @@ -849,7 +869,8 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, if (YYMAXDEPTH < yyalloc) yyalloc = YYMAXDEPTH; yybottom_new = - (yytype_int16*) YYSTACK_ALLOC (yyalloc * sizeof *yybottom_new); + (yytype_int16 *) YYSTACK_ALLOC ((YYSIZE_T) + (yyalloc * YYSIZEOF (*yybottom_new))); if (!yybottom_new) { YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix, @@ -866,8 +887,8 @@ yy_lac_stack_realloc (YYSIZE_T *yycapacity, YYSIZE_T yyadd, *yybottom = yybottom_new; *yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]), [full], [[ - YYDPRINTF ((stderr, "%srealloc to %lu%s", yydebug_prefix, - (unsigned long) yyalloc, yydebug_suffix));]])[ + YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix, + (long) yyalloc, yydebug_suffix));]])[ } return 0; } @@ -953,7 +974,7 @@ do { \ any old *YYES other than YYESA. */ static int yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, - YYSIZE_T *yyes_capacity, yytype_int16 *yyssp, int yytoken) + YYPTRDIFF_T *yyes_capacity, yytype_int16 *yyssp, int yytoken) { yytype_int16 *yyes_prev = yyssp; yytype_int16 *yyesp = yyes_prev; @@ -993,11 +1014,11 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, yyrule = -yyrule; } { - YYSIZE_T yylen = yyr2[yyrule]; + YYPTRDIFF_T yylen = yyr2[yyrule]; YYDPRINTF ((stderr, " R%d", yyrule - 1)); if (yyesp != yyes_prev) { - YYSIZE_T yysize = (YYSIZE_T) (yyesp - *yyes + 1); + YYPTRDIFF_T yysize = yyesp - *yyes + 1; if (yylen < yysize) { yyesp -= yylen; @@ -1050,13 +1071,13 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen +# define yystrlen(S) ((YYPTRDIFF_T) strlen (S)) # else /* Return the length of YYSTR. */ -]b4_function_define([yystrlen], [static YYSIZE_T], +]b4_function_define([yystrlen], [static YYPTRDIFF_T], [[const char *yystr], [yystr]])[ { - YYSIZE_T yylen; + YYPTRDIFF_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; @@ -1092,12 +1113,12 @@ yy_lac (yytype_int16 *yyesa, yytype_int16 **yyes, backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ -static YYSIZE_T +static YYPTRDIFF_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { - YYSIZE_T yyn = 0; + YYPTRDIFF_T yyn = 0; char const *yyp = yystr; for (;;) @@ -1131,7 +1152,7 @@ yytnamerr (char *yyres, const char *yystr) if (! yyres) return yystrlen (yystr); - return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); + return yystpcpy (yyres, yystr) - yyres; } # endif @@ -1146,12 +1167,12 @@ yytnamerr (char *yyres, const char *yystr) required number of bytes is too large to store]b4_lac_if([[ or if yy_lac returned 2]])[. */ static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, +yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, ]b4_lac_if([[yytype_int16 *yyesa, yytype_int16 **yyes, - YYSIZE_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken) + YYPTRDIFF_T *yyes_capacity, ]])[yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; + YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYPTRDIFF_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ const char *yyformat = YY_NULLPTR; @@ -1230,7 +1251,8 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + YYPTRDIFF_T yysize1 = yysize + yytnamerr (YY_NULLPTR, + yytname[yyx]); if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) yysize = yysize1; else @@ -1261,7 +1283,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + YYPTRDIFF_T yysize1 = yysize + yystrlen (yyformat); if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) yysize = yysize1; else @@ -1442,7 +1464,7 @@ b4_function_define([[yyparse]], [[int]], b4_parse_param)[ /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; + YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; #endif #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[) @@ -1508,7 +1530,7 @@ yysetstate: #else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); + YYPTRDIFF_T yysize = yyssp - yyss + 1; # if defined yyoverflow { @@ -1524,9 +1546,9 @@ yysetstate: conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp),]b4_locations_if([ - &yyls1, yysize * sizeof (*yylsp),])[ + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp),]b4_locations_if([ + &yyls1, yysize * YYSIZEOF (*yylsp),])[ &yystacksize); yyss = yyss1; yyvs = yyvs1;]b4_locations_if([ @@ -1543,7 +1565,8 @@ yysetstate: { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + (union yyalloc *) YYSTACK_ALLOC ((YYSIZE_T) + YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); @@ -1559,8 +1582,8 @@ yysetstate: yyvsp = yyvs + yysize - 1;]b4_locations_if([ yylsp = yyls + yysize - 1;])[ - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long) yystacksize)); + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + (long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; @@ -1774,7 +1797,7 @@ yyerrlab: { if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + yymsg = (char *) YYSTACK_ALLOC ((YYSIZE_T) yymsg_alloc); if (!yymsg) { yymsg = yymsgbuf; diff --git a/tests/regression.at b/tests/regression.at index 7ec9ed57..1f308e90 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -661,7 +661,7 @@ AT_BISON_CHECK([-v -o input.c input.y]) [sed -n 's/ *$//;/^static const.*\[\] =/,/^}/p' input.c >tables.c] AT_CHECK([[cat tables.c]], 0, -[[static const yytype_uint8 yytranslate[] = +[[static const yytype_int8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -691,7 +691,7 @@ AT_CHECK([[cat tables.c]], 0, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6 }; -static const yytype_uint8 yyrline[] = +static const yytype_int8 yyrline[] = { 0, 2, 2, 3, 3, 4, 5 }; @@ -700,7 +700,7 @@ static const char *const yytname[] = "$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"", "\"else\"", "$accept", "statement", "struct_stat", "if", "else", YY_NULLPTR }; -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261 }; @@ -709,7 +709,7 @@ static const yytype_int8 yypact[] = -2, -1, 4, -8, 0, 2, -8, -2, -8, -2, -8, -8 }; -static const yytype_uint8 yydefact[] = +static const yytype_int8 yydefact[] = { 3, 0, 0, 2, 0, 0, 1, 3, 4, 3, 6, 5 @@ -722,7 +722,7 @@ static const yytype_int8 yydefgoto[] = { -1, 2, 3, 4, 8 }; -static const yytype_uint8 yytable[] = +static const yytype_int8 yytable[] = { 10, 1, 11, 5, 6, 0, 7, 9 }; @@ -730,16 +730,16 @@ static const yytype_int8 yycheck[] = { 7, 3, 9, 4, 0, -1, 6, 5 }; -static const yytype_uint8 yystos[] = +static const yytype_int8 yystos[] = { 0, 3, 8, 9, 10, 4, 0, 6, 11, 5, 8, 8 }; -static const yytype_uint8 yyr1[] = +static const yytype_int8 yyr1[] = { 0, 7, 8, 9, 9, 10, 11 }; -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { 0, 2, 1, 0, 2, 4, 2 }; -- 2.21.0