From: Akim Demaille Date: Wed, 28 Nov 2001 11:43:24 +0000 (+0000) Subject: * tests/reduce.at (Useless Terminals, Useless Nonterminals): New. X-Git-Tag: before-m4-back-end~249 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/cb4956ee99af6f63b288a6dbb04fc340bb8f8c3b * 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. --- diff --git a/ChangeLog b/ChangeLog index 3723d6e4..99c8ee9b 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 Paul Eggert * src/bison.simple (YYSTACK_REALLOC): Fix typo that caused us to 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 aab87422..485784ef 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 AUTOM4TE = autom4te diff --git a/tests/Makefile.in b/tests/Makefile.in new file mode 100644 index 00000000..be9e3ac6 --- /dev/null +++ b/tests/Makefile.in @@ -0,0 +1,256 @@ +# Makefile.in generated by automake 1.5a from Makefile.am. +# @configure_input@ + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ + +EXEEXT = @EXEEXT@ +OBJEXT = @OBJEXT@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +AMTAR = @AMTAR@ +AWK = @AWK@ +BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CPP = @CPP@ +DATADIRNAME = @DATADIRNAME@ +DEPDIR = @DEPDIR@ +GCC = @GCC@ +GENCAT = @GENCAT@ +GLIBC21 = @GLIBC21@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLBISON = @INTLBISON@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ +LIB = @LIB@ +LIBICONV = @LIBICONV@ +M4 = @M4@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +PACKAGE = @PACKAGE@ +POFILES = @POFILES@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +U = @U@ +USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARNING_CFLAGS = @WARNING_CFLAGS@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +EXTRA_DIST = $(TESTSUITE_AT) testsuite + +DISTCLEANFILES = atconfig atlocal bison package.m4 +MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) + +TESTSUITE_AT = \ + testsuite.at \ + output.at reduce.at calc.at torture.at regression.at + +TESTSUITE = $(srcdir)/testsuite + +AUTOM4TE = autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +subdir = tests +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = atlocal bison +DIST_SOURCES = +DIST_COMMON = Makefile.am Makefile.in atlocal.in bison.in +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +atlocal: $(top_builddir)/config.status atlocal.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +bison: $(top_builddir)/config.status bison.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +uninstall-info-am: +tags: TAGS +TAGS: + + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +all-am: Makefile + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-local mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: installcheck-local + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am check-local clean clean-generic \ + clean-local distclean distclean-generic distdir dvi dvi-am info \ + info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installcheck-local installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + uninstall uninstall-am uninstall-info-am + +$(srcdir)/$(TESTSUITE): $(TESTSUITE_AT) + $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp + mv $@.tmp $@ + +atconfig: $(top_builddir)/config.status + cd $(top_builddir) && ./config.status tests/$@ + +clean-local: + $(SHELL) $(TESTSUITE) --clean + +check-local: atconfig atlocal $(TESTSUITE) + $(SHELL) $(TESTSUITE) + +# Run the test suite on the *installed* tree. +installcheck-local: + $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: 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])