From 0aa2ac9063534e6619ff2ec5f4d6748f7a8ca86b Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 28 Nov 2001 11:42:56 +0000 Subject: [PATCH] * tests/reduce.at (Useless Terminals, Useless Nonterminals): New. * src/reduce.c (reduce_grammar_tables): Do not free useless tags, as all tags are free'ed afterwards. From Enrico Scholz. --- ChangeLog | 7 +++ THANKS | 1 + src/reduce.c | 4 -- tests/Makefile.am | 2 +- tests/Makefile.in | 2 +- tests/reduce.at | 106 +++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 1 + 7 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 tests/reduce.at diff --git a/ChangeLog b/ChangeLog index 00671e1e..174ac491 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-11-28 Akim Demaille + + * tests/reduce.at (Useless Terminals, Useless Nonterminals): New. + * src/reduce.c (reduce_grammar_tables): Do not free useless tags, + as all tags are free'ed afterwards. + From Enrico Scholz. + 2001-11-27 Akim Demaille * src/system.h: Use intl/libgettext.h. diff --git a/THANKS b/THANKS index 346d5977..7b7aa685 100644 --- a/THANKS +++ b/THANKS @@ -8,6 +8,7 @@ Alexander Belopolsky alexb@rentec.com Daniel Hagerty hag@gnu.org David J. MacKenzie djm@gnu.org Dick Streefland dick.streefland@altium.nl +Enrico Scholz enrico.scholz@informatik.tu-chemnitz.de Fabrice Bauzac noon@cote-dazur.com Hans Aberg haberg@matematik.su.se Jesse Thilo jthilo@gnu.org diff --git a/src/reduce.c b/src/reduce.c index a95b4bbd..b4b8dc34 100644 --- a/src/reduce.c +++ b/src/reduce.c @@ -352,10 +352,6 @@ reduce_grammar_tables (void) sprec[n] = sprec[i]; tags[n] = tags[i]; } - else - { - free (tags[i]); - } } /* Replace all symbol numbers in valid data structures. */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 90cac9c7..0a4c0bc6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,7 +25,7 @@ MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) TESTSUITE_AT = \ testsuite.at \ - output.at calc.at torture.at regression.at + output.at reduce.at calc.at torture.at regression.at TESTSUITE = $(srcdir)/testsuite AUTOTEST = $(AUTOM4TE) --language=autotest diff --git a/tests/Makefile.in b/tests/Makefile.in index eb8fa727..5d9cefae 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -108,7 +108,7 @@ MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) TESTSUITE_AT = \ testsuite.at \ - output.at calc.at torture.at regression.at + output.at reduce.at calc.at torture.at regression.at TESTSUITE = $(srcdir)/testsuite diff --git a/tests/reduce.at b/tests/reduce.at new file mode 100644 index 00000000..ed3a5150 --- /dev/null +++ b/tests/reduce.at @@ -0,0 +1,106 @@ +# Exercising Bison Grammar Reduction. -*- Autotest -*- +# Copyright 2001 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +AT_BANNER([[Grammar Reduction.]]) + + +## ------------------- ## +## Useless Terminals. ## +## ------------------- ## + +AT_SETUP([Useless Terminals]) + +AT_DATA([[input.y]], +[[%verbose +%output="input.c" + +%token useless1 +%token useless2 +%token useless3 +%token useless4 +%token useless5 +%token useless6 +%token useless7 +%token useless8 +%token useless9 + +%token useful +%% +exp: useful; +]]) + +AT_CHECK([[bison input.y]]) + +AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, +[[Terminals which are not used: + useless1 + useless2 + useless3 + useless4 + useless5 + useless6 + useless7 + useless8 + useless9 +]]) + +AT_CLEANUP + + + +## ---------------------- ## +## Useless Nonterminals. ## +## ---------------------- ## + +AT_SETUP([Useless Nonterminals]) + +AT_DATA([[input.y]], +[[%verbose +%output="input.c" + +%nterm useless1 +%nterm useless2 +%nterm useless3 +%nterm useless4 +%nterm useless5 +%nterm useless6 +%nterm useless7 +%nterm useless8 +%nterm useless9 + +%token useful +%% +exp: useful; +]]) + +AT_CHECK([[bison input.y]]) + +AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, +[[Terminals which are not used: + useless1 + useless2 + useless3 + useless4 + useless5 + useless6 + useless7 + useless8 + useless9 +]]) + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index e1a49e17..b59f5802 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -26,6 +26,7 @@ AT_INIT AT_TESTED([bison]) m4_include([output.at]) +m4_include([reduce.at]) m4_include([calc.at]) m4_include([torture.at]) m4_include([regression.at]) -- 2.50.0