Files
bison/tests
Akim Demaille 2f7097d1b1 yacc.c, glr.c: fix crash when reporting errors in consistent states
The current code for yysyntax_error for %define parse.error verbose is
fishy (given that YYEMPTY is -2, invalid argument for yytname[]):

    static int
    yysyntax_error ([...])
    {
      YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
    [...]
      if (yytoken != YYEMPTY)

A nearby comment reports

    The only way there can be no lookahead present (in yychar) is if
    this state is a consistent state with a default action.  Thus,
    detecting the absence of a lookahead is sufficient to determine
    that there is no unexpected or expected token to report.  In that
    case, just report a simple "syntax error".

So it _is_ possible to call yysyntax_error with yytoken == YYEMPTY,
albeit quite difficult when meaning to, so virtually impossible by
accident (after all, there was never a bug report about this).

I failed to produce a test case, but Joel E. Denny provided me with
one (added to the test suite below).  The yacc.c skeleton fails on
this, and once fixed dies on a second problem.  The glr.c skeleton was
also dying, but immediately of this second problem.

Indeed we were not allocating space for the error message's final \0.
This was hidden by the fact that we only had error messages with at
least an unexpected token displayed, so with at least one "%s" in the
format string, whose size (2) was included (incorrectly) in the final
size of the message (where the %s have been replaced by the actual
content).

* data/skeletons/glr.c, data/skeletons/yacc.c (yysyntax_error):
Do not invoke yytnamerr on YYEMPTY.
Clarify the computation of the length of the _final_ error message,
with the NUL terminator but without the '%s's.
* tests/conflicts.at (Syntax error in consistent error state):
New, contributed by Joel E. Denny.
2019-11-29 18:21:43 +01:00
..
2019-02-21 06:46:07 +01:00
2019-10-10 17:53:48 +02:00
2019-11-01 12:04:13 +01:00
2019-10-13 09:22:05 +02:00
2019-10-13 09:22:05 +02:00
2019-11-02 16:40:50 +01:00
2019-04-24 13:21:24 +02:00
2019-11-02 16:40:50 +01:00
2019-11-02 16:40:50 +01:00
2019-06-19 19:15:31 +02:00
2019-09-14 10:09:08 +02:00
2019-10-13 09:22:05 +02:00
2019-02-21 17:46:11 +01:00
2019-04-23 18:29:10 +02:00
2019-02-09 08:23:50 +01:00
2019-10-17 11:51:20 -07:00
2019-09-14 09:55:17 +02:00
2019-11-03 10:32:22 +01:00
2019-11-02 16:40:50 +01:00
2019-11-02 16:40:50 +01:00