tables: avoid warnings and save bits
commit1d3df34671ad4f0f60fef87558c6eb87b572eb14
authorAkim Demaille <akim.demaille@gmail.com>
Wed, 2 Dec 2020 20:39:26 +0000 (2 21:39 +0100)
committerAkim Demaille <akim.demaille@gmail.com>
Sat, 23 Jan 2021 08:36:24 +0000 (23 09:36 +0100)
tree0c3c194eba895ceb657d9b6b3444485893757130
parent89d2b69c1b926c9dc1da3834ba2a7a924d4e2d4f
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.
src/parse-gram.c
src/parse-gram.h
src/tables.c
tests/regression.at