Fix precedence for end token.

Since Bison 2.3b, which restored the ability of precedence
directives to assign user token numbers, doing so for user token
number 0 has produced an assertion failure.
* NEWS (2.5): Document fix.
* src/symtab.c (symbol_user_token_number_set): In the case of the
end token, don't decrement ntokens if it was never incremented.
* tests/regression.at (Token number in precedence declaration):
Extend.
This commit is contained in:
Joel E. Denny
2011-05-01 21:53:35 -04:00
parent 441735026b
commit 9d6af15318
4 changed files with 32 additions and 5 deletions

View File

@@ -368,10 +368,11 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
if (user_token_number == 0)
{
endtoken = sym;
endtoken->number = 0;
/* It is always mapped to 0, so it was already counted in
NTOKENS. */
--ntokens;
if (endtoken->number != NUMBER_UNDEFINED)
--ntokens;
endtoken->number = 0;
}
}