]> git.saurik.com Git - bison.git/commitdiff
* tests/reduce.at (Useless Terminals, Useless Nonterminals): New.
authorAkim Demaille <akim@epita.fr>
Wed, 28 Nov 2001 11:42:56 +0000 (11:42 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 28 Nov 2001 11:42:56 +0000 (11:42 +0000)
* src/reduce.c (reduce_grammar_tables): Do not free useless tags,
as all tags are free'ed afterwards.
From Enrico Scholz.

ChangeLog
THANKS
src/reduce.c
tests/Makefile.am
tests/Makefile.in
tests/reduce.at [new file with mode: 0644]
tests/testsuite.at

index 00671e1e2e34102c897a69f5c4205aaf4afbeb94..174ac491417c01ea0e3ddcfb6af1b1e3a6e20c64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-11-28  Akim Demaille  <akim@epita.fr>
+
+       * 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  <akim@epita.fr>
 
        * src/system.h: Use intl/libgettext.h.
diff --git a/THANKS b/THANKS
index 346d5977bd0e52abb2d8272b4cb50055ad5b32b4..7b7aa68539fd553eb4af5174b3f94c93d5c446f9 100644 (file)
--- 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
index a95b4bbd57d7aebf2d3bda2140ad39df6192b4de..b4b8dc34cfd4ee120707c6ebbde486cb2658e024 100644 (file)
@@ -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.  */
index 90cac9c770b2579c5a8c943110677a99d35d37c6..0a4c0bc649acd403a8b07c41bc4a7bc4fb07e5ee 100644 (file)
@@ -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
index eb8fa7277c4fbfc163565313f2803541fa1bee6a..5d9cefae3f2bcf8235a2f75508fa498edfb7c372 100644 (file)
@@ -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 (file)
index 0000000..ed3a515
--- /dev/null
@@ -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
index e1a49e172624ca16164c9694945dbec0c962f086..b59f5802b612e5762cdd041fa0e02080cb89c459 100644 (file)
@@ -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])