tables: avoid warnings and save bits

The yydefgoto table uses -1 as an invalid for an impossible case (we
never use yydefgoto[0], since it corresponds to the reduction to
$accept, which never happens).  Since yydefgoto is a table of state
numbers, this -1 forces a signed type uselessly, which (1) might
trigger compiler warnings when storing a value from yydefgoto into a
state number (nonnegative), and (2) wastes bits which might result in
using a int16 where a uint8 suffices.

Reported by Jot Dot <jotdot@shaw.ca>.
https://lists.gnu.org/r/bug-bison/2020-11/msg00027.html

* src/tables.c (default_goto): Use 0 rather than -1 as invalid value.
* tests/regression.at: Adjust.
This commit is contained in:
Akim Demaille
2020-12-02 21:39:26 +01:00
parent 89d2b69c1b
commit 1d3df34671
4 changed files with 29 additions and 10 deletions

View File

@@ -737,7 +737,7 @@ static const yytype_int8 yypgoto[] =
};
static const yytype_int8 yydefgoto[] =
{
-1, 2, 3, 4, 8
0, 2, 3, 4, 8
};
static const yytype_int8 yytable[] =
{