Akim Demaille [Fri, 16 Jan 2015 08:25:37 +0000 (09:25 +0100)]
build: avoid infinite recursions on include_next
On MacOS X 10.5 PPC with Apple's GCC 4.0.1:
% uname -a
Darwin aria.cielonegro.org 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:0
1 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh
% gcc --version
powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5493)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
building in place enters into an infinite recursion on "#include_next":
% gmake V=1
[snip]
depbase=`echo lib/math.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu99 -I. -Ilib -I. -I./lib -g -O2 -MT lib/math.o -MD -MP -MF $depbase.Tpo -c -o lib/math.o lib/math.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from lib/math.h:27,
from lib/math.h:27,
from lib/math.h:27,
from lib/math.h:27,
[snip]
from lib/math.h:27,
from lib/math.h:27,
from lib/math.c:3:
lib/math.h:27:23: error: #include nested too deeply
Makefile:3414: recipe for target 'lib/math.o' failed
gmake[2]: *** [lib/math.o] Error 1
Using -I./lib instead of -Ilib fixes the problem.
Reported by Pho.
<https://lists.gnu.org/archive/html/bison-patches/2014-01/msg00000.html>
* Makefile.am (AM_CPPFLAGS): Use -I./lib instead of -Ilib.
Akim Demaille [Tue, 13 Jan 2015 13:15:47 +0000 (14:15 +0100)]
tests: split a large test case into several smaller ones
* tests/conflicts.at (AT_CONSISTENT_ERRORS_CHECK): Move AT_SETUP/AT_CLEANUP
into it, so that we don't skip non Java tests following a test case in Java.
Akim Demaille [Fri, 9 Jan 2015 13:21:09 +0000 (14:21 +0100)]
bison: avoid warnings from static code analysis
A static analysis tool reports that some callers of symbol_list_n_get
might get NULL and not handle it properly. This is not the case, yet
we can suppress this pattern.
Reported by Mike Sullivan.
<https://lists.gnu.org/archive/html/bug-bison/2013-12/msg00027.html>
* src/symlist.c (symbol_list_n_get): Actually it is never called
to return 0. Enforce this postcondition via aver.
(symbol_list_n_type_name_get): Simplify accordingly. In particular,
discards a (translated) useless error message.
* src/symlist.h: Adjust documentation.
* src/scan-code.l: Style change.
Akim Demaille [Fri, 9 Jan 2015 11:01:22 +0000 (12:01 +0100)]
c++: fix the use of destructors when variants are enabled
When using variants, destructors generate invalid code.
<http://lists.gnu.org/archive/html/bug-bison/2014-09/msg00005.html>
Reported by Michael Catanzaro.
* data/c++.m4 (~basic_symbol): b4_symbol_foreach works on yysym:
define it.
* tests/c++.at (Variants): Check it.
Akim Demaille [Thu, 8 Jan 2015 12:37:16 +0000 (13:37 +0100)]
c++: symbols can be empty, so use it
The previous patches ensure that symbols (symbol_type and
stack_symbol_type) can be empty, cleared, and their emptiness can be
checked. Therefore, yyempty, which codes whether yyla is empty or
not, is now useless.
In C skeletons (e.g., yacc.c), the fact that the lookahead is empty is
coded by "yychar = YYEMPTY", which is exactly what this patch
restores, since yychar/yytoken corresponds to yyla.type.
* data/lalr1.cc (yyempty): Remove.
Rather, depend on yyla.empty ().
Akim Demaille [Thu, 8 Jan 2015 09:19:10 +0000 (10:19 +0100)]
c++: provide a means to clear symbols
The symbol destructor is currently the only means to clear a symbol.
Unfortunately during error recovery we might have to clear the
lookahead, which is a local variable (yyla) that has not yet reached
its end of scope.
Rather that duplicating the code to destroy a symbol, or rather than
destroying and recreating yyla, let's provide a means to clear a
symbol.
Reported by Antonio Silva Correia, with an analysis from Michel d'Hooge.
<http://savannah.gnu.org/support/?108481>
* data/c++.m4, data/lalr1.cc (basis_symbol::clear, by_state::clear)
(by_type::clear): New.
(basic_symbol::~basic_symbol): Use clear.
Akim Demaille [Wed, 7 Jan 2015 09:24:53 +0000 (10:24 +0100)]
c++: variants: comparing addresses of typeid.name() is undefined
Instead of storing and comparing pointers to names of types, store
pointers to the typeids, and compares the typeids.
Reported by Thomas Jahns.
<http://lists.gnu.org/archive/html/bug-bison/2014-03/msg00001.html>
Akim Demaille [Fri, 29 Aug 2014 21:36:20 +0000 (00:36 +0300)]
build: don't try to generate docs when cross-compiling
When cross-compiling don't run the generated bison to update the docs.
Reported by Aaro Koskinen.
<http://lists.gnu.org/archive/html/bison-patches/2014-03/msg00000.html>
* configure.ac (CROSS_COMPILING): New.
* doc/local.mk: Use it.
Akim Demaille [Sun, 4 Jan 2015 13:16:23 +0000 (14:16 +0100)]
%union: fix the support for named %union
Bison supports a union tag, for obscure reasons. But it does a poor
job at it, especially since Bison 3.0.
Reported by Stephen Cameron and Tobias Frost.
It did not ensure that the name was not given several times. An easy
way to do this is to make the %union tag be handled as a %define
variable, as they cannot be defined several times.
Since Bison 3.0, the synclines were wrongly placed, resulting in
invalid code. Addressing this issue, because of the way the union tag
was stored (as a code muscle), would have been tedious. Unless we
rather define the %union tag as a %percent variable, whose synclines
are easier to manipulate.
So replace the b4_union_name muscle by the api.value.union.name
%define variable, document, and check.
* data/bison.m4: Make sure that api.value.union.name has a keyword value.
* data/c++.m4: Make sure that api.value.union.name is not defined.
* data/c.m4 (b4_union_name): No longer use it, use api.value.union.name.
* doc/bison.texi (%define Summary): Document it.
* src/parse-gram.y (union_name): No longer define b4_uion_name, but
api.value.union.name.
* tests/input.at (Redefined %union name): New.
* tests/synclines.at (%union name syncline): New.
* tests/types.at: Check named %unions.
Akim Demaille [Wed, 31 Dec 2014 13:15:06 +0000 (14:15 +0100)]
yacc.c: fix broken union when api.value.type=union and %defines are used
Reported by Rich Wilson.
* data/c.m4 (b4_symbol_type_register): Append to b4_union_members,
not b4_user_union_members.
The latter invokes the former, but it is the former which is reinitialized
to empty by b4_value_type_setup_union.
* tests/types.at: Check it.
This reveals another bug, this time in the case of glr.c parsers.
* data/glr.c: Generate the header file before the implementation file,
to be sure that the setup is run before what depends on it.
Akim Demaille [Mon, 3 Feb 2014 14:01:44 +0000 (15:01 +0100)]
build: use abort to pacify compiler errors
clang, with -DNDEBUG and -Werror fails on some functions that might
lack a return. This is because aver is just another assert, discarded
with -DNDEBUG. So use abort.
Paul Eggert [Fri, 3 Jan 2014 19:02:58 +0000 (11:02 -0800)]
doc: specify documentation encoding
* doc/bison.texi: Add '@documentencoding UTF-8'; needed since the
manual contains UTF-8 characters. This will cause the .info files
to contain UTF-8 quotes and the like, which should be OK nowadays.
Add @documentlanguage while we're at it.
Akim Demaille [Mon, 9 Dec 2013 15:29:05 +0000 (16:29 +0100)]
package: install the examples
Currently, we do not install the various examples extracted from the
documentation. Let's do it, as they are useful starting points.
* configure.ac: When --enable-gcc-warnings is set, enable ENABLE_GCC_WARNINGS.
* examples/extexi: No longer issue synclines by default.
* examples/local.mk: Except if ENABLE_GCC_WARNINGS.
* examples/calc++/local.mk, examples/mfcalc/local.mk,
* examples/rpcalc/local.mk: Install the example files.
Akim Demaille [Wed, 4 Dec 2013 09:51:47 +0000 (10:51 +0100)]
output: do not generate source files when late errors are caught
Reported by Alexandre Duret-Lutz as "second problem" in:
http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html
* bootstrap.conf: We need the "unlink" module.
* src/files.h, src/files.c (unlink_generated_sources): New.
* src/output.c: Use it.
* tests/output.at: Check the case of late errors.
Akim Demaille [Wed, 4 Dec 2013 09:26:46 +0000 (10:26 +0100)]
output: record what generated files are source or report files
* src/files.h, src/files.c (output_file_name_check): Take an additional
argument to record whether a file is a source or report file.
* src/files.c (generated_file): New.
(file_names, file_names_count): Replace with...
(generated_files, generated_files_size): these.
* src/scan-skel.l: Adjust.
Akim Demaille [Wed, 4 Dec 2013 08:30:08 +0000 (09:30 +0100)]
output: do not generate source files when early errors are caught
Reported by Alexandre Duret-Lutz as "second problem" in:
http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html
One problem is that some errors are caught early, before the
generation of output files, while others can only be detected
afterwards (since, for instance, skeletons can raise errors
themselves).
This will be addressed in two steps: early errors do not generate
source files at all, while later errors will remove the files that
have already been generated.
* src/scan-skel.l (yyout): Open to /dev/null when there are errors.
* tests/output.at (AT_CHECK_FILES): Factored out of...
(AT_CHECK_OUTPUT): this.
Fuse the "SHELLIO" argument in the "FLAGS" one.
Use $5 to denote the expected exit status.
Add a test case for early errors.
Akim Demaille [Fri, 15 Nov 2013 09:08:31 +0000 (10:08 +0100)]
lalr1.cc: fix the support of YYERROR with variants
When variant are enabled, the yylhs variable (the left-hand side of
the rule being reduced, i.e. $$ and @$) is explicitly destroyed when
YYERROR is called. This is because before running the user code, $$
is initialized, so that the user can properly use it.
However, when quitting yyparse, yylhs is also reclaimed by the C++
compiler: the variable goes out of scope.
Instead of trying to be too smart, let the compiler do its job: reduce
the scope of yylhs to exactly the reduction. This way, whatever the
type of scope exit (regular, exception, return, goto...) this variable
will be properly reclaimed.
Reported by Paolo Simone Gasparello.
<http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00003.html>
* data/lalr1.cc (yyparse): Reduce the scope of yylhs.
* tests/c++.at: We now pass this test.
Akim Demaille [Fri, 15 Nov 2013 08:43:01 +0000 (09:43 +0100)]
tests: check $$'s destruction with variant, YYERROR, and no error recovery
When variant are enabled, the yylhs variable (the left-hand side of
the rule being reduced, i.e. $$ and @$) is explicitly destroyed when
YYERROR is called. This is because before running the user code, $$
is initialized, so that the user can properly use it.
However, when quitting yyparse, yylhs is also reclaimed by the C++
compiler: the variable goes out of scope.
This was not detected by the test suite because (i) the Object tracker
was too weak, and (ii) the problem does not show when there is error
recovery.
Reported by Paolo Simone Gasparello.
<http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00003.html>
* tests/c++.at (Exception safety): Improve the objects logger to make
sure that we never destroy twice an object.
Also track copy-constructors.
Use a set instead of a list.
Display the logs before running the function body, this is more
useful in case of failure.
Generalize to track with and without error recovery.
Akim Demaille [Thu, 14 Nov 2013 15:14:39 +0000 (16:14 +0100)]
skeletons: use better names when computing a "goto"
* data/glr.c (yyLRgotoState): Name the symbol argument yysym, instead
of yylhs.
* data/lalr1.cc (yy_lr_goto_state_): Likewise.
* data/lalr1.java (yy_lr_goto_state_): New, modeled after the previous
two routines.
Use it.
Akim Demaille [Wed, 23 Oct 2013 08:57:51 +0000 (10:57 +0200)]
c++: use __attribute__((__pure__)) to avoid warnings
Building C++ parsers with -Wsuggest-attribute=const and
-Wsuggest-attribute=noreturn triggers warning in generated code.
* data/lalr1.cc: Call b4_attribute_define.
(debug_stream, debug_level): Flag as pure.
* tests/headers.at (Several parsers): There are now more YY macros
that "leak".
Akim Demaille [Tue, 22 Oct 2013 15:32:49 +0000 (17:32 +0200)]
install: do not install yacc.1 when --disable-yacc
* configure.ac (ENABLE_YACC): New conditional.
(YACC_SCRIPT, YACC_LIBRARY): Remove.
* lib/local.mk, src/local.mk: Use the former instead of the latter.
* doc/local.mk: Use ENABLE_YACC to avoid installing yacc.1.
Paul Eggert [Mon, 21 Oct 2013 22:21:32 +0000 (15:21 -0700)]
bison: pacify Sun C 5.12
* src/scan-code.l (show_sub_message):
Redo initializations to work around a bogus Sun C 5.12 warning.
(parse_ref): Remove unreachable code that Sun C 5.12 complains about.
* src/uniqstr.h (uniqstr_vsprintf): Use
_GL_ATTRIBUTE_FORMAT_PRINTF (...) instead of __attribute__
((__format__ (__printf__, ...))). Otherwise, Sun C 5.12
complains about an unknown attribute.
Paul Eggert [Mon, 21 Oct 2013 22:16:43 +0000 (15:16 -0700)]
build: examples/calc++/calc++ requires flex
* configure.ac (FLEX_CXX_WORKS): New AM_CONDITIONAL.
* examples/calc++/local.mk (examples/calc++/calc++):
Build if FLEX_CXX_WORKS, not BISON_CXX_WORKS.
Akim Demaille [Wed, 16 Oct 2013 08:55:28 +0000 (10:55 +0200)]
diagnostics: "-Werror -Wno-error=foo" must not emit errors
Currently "-Werror -Wno-error=foo" still turns "foo" warnings into errors.
Reported by Alexandre Duret-Lutz.
See http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html.
* src/complain.c (errority, errority_flag): New.
(complain_init): Initialize the latter.
(warning_argmatch): Extract the loop iterating on the flag's bits.
Set and unset errority_flag here.
(warnings_argmatch): -Wno-error is not the same as -Wno-error=everything:
we must remember if category foo was explicitly turned in an error/warning
via -W(no-)error=foo.
(warning_severity): Use errority_flag.
* tests/input.at (Symbols): Just check --yacc, not -Wyacc, that's the
job of tests on -W.
(-Werror is not affected by -Wnone and -Wall): Rename as...
(-Werror combinations): this.
Tests more combinations of -W, -W(no-)error, and -W(no-)error=foo.
* tests/local.at (AT_BISON_CHECK_WARNINGS): Don't expect -Werror
to turn runs that issue warnings into runs with errors, as the
warnings might be enforced as warnings by -Wno-error=foo, in which
case -Werror does not change anything.
* doc/bison.texi (Bison Options): Try to be clearer about how
-W(no-)error and -W(no-)error=foo interact.
Paul Eggert [Sun, 25 Aug 2013 01:22:22 +0000 (18:22 -0700)]
build: don't require flex for ordinary builds
* configure.ac (LEX): Don't fail if this is lex, as flex is not
required for ordinary builds. Instead, issue a warning and
substitute a no-op LEX. Reported by Michael Felt in
<http://lists.gnu.org/archive/html/bug-bison/2013-08/msg00009.html>.
Paul Eggert [Sat, 24 Aug 2013 14:52:27 +0000 (07:52 -0700)]
build: port to pre-5.8.7 perl
* examples/local.mk (extract): Omit -f from perl options.
This doesn't work with perl versions before 5.8.7
that are configured without USE_SITECUSTOMIZE.
Reported by Michael Felt in
<http://lists.gnu.org/archive/html/bug-bison/2013-08/msg00006.html>.