mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 12:53:03 +00:00
yysyntax_error: avoid duplicate lookahead collection.
Except when memory reallocation is required, this change eliminates the need to invoke yysyntax_error twice and thus to repeat the collection of lookaheads. It also prepares for future extensions that will make those repetitions more expensive and that will require additional memory management in yysyntax_error. Finally, it fixes an obscure bug already exercised in the test suite. * data/yacc.c (yysyntax_error): Add arguments for message buffer variables stored in the parser. Instead of size, return status similar to yyparse status but indicating success of message creation. Other than the actual reallocation of the message buffer, import and clean up memory management code from... (yyparse, yypush_parse): ... here. * tests/regression.at (parse.error=verbose overflow): No longer an expected failure.
This commit is contained in:
@@ -1350,16 +1350,13 @@ AT_CLEANUP
|
||||
# Imagine the case where YYSTACK_ALLOC_MAXIMUM = YYSIZE_MAXIMUM and an
|
||||
# invocation of yysyntax_error has caused yymsg_alloc to grow to exactly
|
||||
# YYSTACK_ALLOC_MAXIMUM (perhaps because the normal doubling of size had
|
||||
# to be clipped to YYSTACK_ALLOC_MAXIMUM). Now imagine a subsequent
|
||||
# invocation of yysyntax_error that overflows during its size
|
||||
# calculation and thus returns YYSIZE_MAXIMUM to yyparse. Then, yyparse
|
||||
# will invoke yyerror using the old contents of yymsg. This bug needs
|
||||
# to be fixed.
|
||||
# to be clipped to YYSTACK_ALLOC_MAXIMUM). In an old version of yacc.c,
|
||||
# a subsequent invocation of yysyntax_error that overflows during its
|
||||
# size calculation would return YYSIZE_MAXIMUM to yyparse. Then,
|
||||
# yyparse would invoke yyerror using the old contents of yymsg.
|
||||
|
||||
AT_SETUP([[parse.error=verbose overflow]])
|
||||
|
||||
AT_XFAIL_IF([[:]])
|
||||
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[[%code {
|
||||
#include <stdio.h>
|
||||
|
||||
Reference in New Issue
Block a user