From 1bd0dedaaa08858f4ad13a11a75d814fd7ceb5ce Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 16 Sep 2005 22:54:21 +0000 Subject: [PATCH] * NEWS: Version 2.1. * NEWS: Remove notice of yytname change, since it was never in an official release. * data/glr.c (yydestroyGLRState): Rename local var to avoid shadowing diagnostic. * src/output.c (prepare): Likewise. * data/lalr1.cc (YYERROR_VERBOSE_IF): New macro. (yysyntax_error_): Use it to avoid GCC warning when YYERROR_VERBOSE is not defined. This is an awful hack, but it's enough for now. All callers changed. * tests/glr-regression-at (make_value): Args are const pointers now, to avoid GCC warning. (Duplicated user destructor for lookahead): New test. Currently skipped. It fails on my host but I'm not sure it'll always fail. --- ChangeLog | 22 ++++++++++-- NEWS | 7 +--- configure.ac | 2 +- data/glr.c | 8 ++--- data/lalr1.cc | 12 +++++-- src/output.c | 4 +-- tests/glr-regression.at | 90 ++++++++++++++++++++++++++++++++++++++++++++++--- 7 files changed, 122 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9996394..64f4b1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,29 @@ -2005-09-16 Akim +2005-09-16 Paul Eggert + + * NEWS: Version 2.1. + + * NEWS: Remove notice of yytname change, since it was never in an + official release. + * data/glr.c (yydestroyGLRState): Rename local var to avoid shadowing + diagnostic. + * src/output.c (prepare): Likewise. + * data/lalr1.cc (YYERROR_VERBOSE_IF): New macro. + (yysyntax_error_): Use it to avoid GCC warning when YYERROR_VERBOSE + is not defined. This is an awful hack, but it's enough for now. + All callers changed. + * tests/glr-regression-at (make_value): Args are const pointers now, + to avoid GCC warning. + (Duplicated user destructor for lookahead): New test. Currently + skipped. It fails on my host but I'm not sure it'll always fail. + +2005-09-16 Akim Demaille * src/symtab.h (struct symbol): Declare the printer and destructor as const, to avoid accidental calls to free. (symbol_destructor_set, symbol_printer_set): Adjust. * src/symtab.c: Adjust. -2005-09-16 Akim +2005-09-16 Akim Demaille * data/c.m4 (b4_token_enums): New. (b4_token_defines): Rename as... diff --git a/NEWS b/NEWS index fa198bb..5ce9863 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ Bison News ---------- -Changes in version 2.0b, 2005-07-24: +Changes in version 2.1, 2005-09-16: * Bison-generated parsers now support the translation of diagnostics like "syntax error" into languages other than English. The default @@ -19,11 +19,6 @@ Changes in version 2.0b, 2005-07-24: behind on the stack. Also, the start symbol is now destroyed after a successful parse. In both cases, the behavior was formerly inconsistent. -* The yytname array now contains the same contents that it did in 2.0, - undoing an incompatible and undocumented change made in 2.0a. - -Changes in version 2.0a, 2005-05-22: - * When generating verbose diagnostics, Bison-generated parsers no longer quote the literal strings associated with tokens. For example, for a syntax error associated with '%token NUM "number"' they might diff --git a/configure.ac b/configure.ac index 0fe6554..cf6b688 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ # least Autoconf 2.59. AC_PREREQ(2.59) -AC_INIT([GNU Bison], [2.0c], [bug-bison@gnu.org]) +AC_INIT([GNU Bison], [2.1], [bug-bison@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/data/glr.c b/data/glr.c index 244c430..6d3ec6c 100644 --- a/data/glr.c +++ b/data/glr.c @@ -920,12 +920,12 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys) if (yys->yysemantics.yyfirstVal) { yySemanticOption *yyoption = yys->yysemantics.yyfirstVal; - yyGLRState *yyrhs; + yyGLRState *yyrh; int yyn; - for (yyrhs = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule); + for (yyrh = yyoption->yystate, yyn = yyrhsLength (yyoption->yyrule); yyn > 0; - yyrhs = yyrhs->yypred, yyn -= 1) - yydestroyGLRState (yymsg, yyrhs); + yyrh = yyrh->yypred, yyn -= 1) + yydestroyGLRState (yymsg, yyrh); } } } diff --git a/data/lalr1.cc b/data/lalr1.cc index 043b082..2ab900b 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -69,6 +69,12 @@ b4_syncline([@oline@], [@ofile@])[ # define YYERROR_VERBOSE ]b4_error_verbose[ #endif +#if YYERROR_VERBOSE +# define YYERROR_VERBOSE_IF(x) x +#else +# define YYERROR_VERBOSE_IF(x) /* empty */ +#endif + /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE ]b4_token_table[ @@ -176,7 +182,7 @@ namespace yy /// Generate an error message. /// \param tok the look-ahead token. - virtual std::string yysyntax_error_ (int tok); + virtual std::string yysyntax_error_ (YYERROR_VERBOSE_IF (int tok)); #if YYDEBUG /// \brief Report a symbol on the debug stream. @@ -695,7 +701,7 @@ yyerrlab: if (!yyerrstatus_) { ++yynerrs_; - error (yylloc, yysyntax_error_ (yyilooka)); + error (yylloc, yysyntax_error_ (YYERROR_VERBOSE_IF (yyilooka))); } yyerror_range[0] = yylloc; @@ -816,7 +822,7 @@ yyreturn: // Generate an error message. std::string -yy::]b4_parser_class_name[::yysyntax_error_ (int tok) +yy::]b4_parser_class_name[::yysyntax_error_ (YYERROR_VERBOSE_IF (int tok)) { std::string res; #if YYERROR_VERBOSE diff --git a/src/output.c b/src/output.c index 3839412..5b12f72 100644 --- a/src/output.c +++ b/src/output.c @@ -618,8 +618,8 @@ prepare (void) /* About the skeletons. */ { - char const* p = getenv ("BISON_PKGDATADIR"); - MUSCLE_INSERT_STRING ("pkgdatadir", p ? p : PKGDATADIR); + char const *pkgdatadir = getenv ("BISON_PKGDATADIR"); + MUSCLE_INSERT_STRING ("pkgdatadir", pkgdatadir ? pkgdatadir : PKGDATADIR); MUSCLE_INSERT_C_STRING ("skeleton", skeleton); } } diff --git a/tests/glr-regression.at b/tests/glr-regression.at index 6f6562c..966730b 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -338,7 +338,8 @@ AT_CLEANUP AT_SETUP([Duplicate representation of merged trees]) AT_DATA_GRAMMAR([glr-regr4.y], -[[%union { char *ptr; } +[[ +%union { char *ptr; } %type S A A1 A2 B %glr-parser @@ -347,7 +348,7 @@ AT_DATA_GRAMMAR([glr-regr4.y], #include #include static char *merge (YYSTYPE, YYSTYPE); - static char *make_value (char *, char *); + static char *make_value (char const *, char const *); static void yyerror (char const *); static int yylex (void); %} @@ -386,7 +387,7 @@ main (void) } static char * -make_value (char *parent, char *child) +make_value (char const *parent, char const *child) { char const format[] = "%s <- %s"; char *value = @@ -433,7 +434,8 @@ AT_CLEANUP AT_SETUP([User destructor for unresolved GLR semantic value]) AT_DATA_GRAMMAR([glr-regr5.y], -[[%{ +[[ +%{ #include #include static void yyerror (char const *); @@ -503,7 +505,8 @@ AT_CLEANUP AT_SETUP([User destructor after an error during a split parse]) AT_DATA_GRAMMAR([glr-regr6.y], -[[%{ +[[ +%{ #include #include static void yyerror (char const *); @@ -556,3 +559,80 @@ AT_CHECK([[./glr-regr6]], 0, ]) AT_CLEANUP + + +## ------------------------------------------------------------------------- ## +## Duplicated user destructor for lookahead ## +## Thanks to Joel E. Denny for this test; see ## +## . ## +## ------------------------------------------------------------------------- ## + +AT_SETUP([Duplicated user destructor for lookahead]) + +AT_DATA_GRAMMAR([glr-regr7.y], +[[ +%{ + #include + #include + static void yyerror (char const *); + static int yylex (void); + #define YYSTACKEXPANDABLE 0 +%} + +%glr-parser +%union { int *count; } +%type 'a' + +%destructor { + if ((*$$)++) + fprintf (stderr, "Destructor called on same value twice.\n"); +} 'a' + +%% + +start: + stack1 start + | stack2 start + | /* empty */ + ; +stack1: 'a' ; +stack2: 'a' ; + +%% + +static int +yylex (void) +{ + yylval.count = malloc (sizeof (int)); + if (!yylval.count) + { + fprintf (stderr, "Test inconclusive.\n"); + exit (EXIT_FAILURE); + } + *yylval.count = 0; + return 'a'; +} + +static void +yyerror (char const *msg) +{ + fprintf (stderr, "%s\n", msg); +} + +int +main (void) +{ + return yyparse (); +} +]]) + +AT_CHECK([[bison -o glr-regr7.c glr-regr7.y]], 0, [], +[glr-regr7.y: conflicts: 2 reduce/reduce +]) +AT_COMPILE([glr-regr7]) + +AT_CHECK([[exit 77; ./glr-regr7]], 2, [], +[memory exhausted +]) + +AT_CLEANUP -- 2.7.4