Predicates with GLR are issued with synclines in the middle of C code:
case 2:
if (! (#line 6 "sempred.y" /* glr.c:816 */
new_syntax)) YYERROR;
#line 793 "sempred.tab.c" /* glr.c:816 */
break;
Reported by Rici Lake.
http://lists.gnu.org/archive/html/bug-bison/2018-05/msg00033.html
* data/c.m4 (b4_predicate_case): Be sure to start on column 0.
It would be nicer if b4_syncline could ensure this by itself
(that would avoid ugly code when synclines are disabled), but that's
way more work.
* tests/glr-regression.at (Predicates): Be a real end-to-end test.
This would have caught this error years ago...
For instance on test 99:
In file included from @@.cc:56:
@@.hh:409:26: error: definition of implicit copy constructor for
'stack_symbol_type' is deprecated because it
has a user-declared copy assignment operator
[-Werror,-Wdeprecated]
stack_symbol_type& operator= (const stack_symbol_type& that);
^
Reported by Derek Clegg.
https://lists.gnu.org/archive/html/bison-patches/2018-05/msg00036.html
* configure.ac (warn_tests): Add -Wdeprecated.
* data/lalr1.cc (stack_symbol_type): Add an explicit copy ctor.
We cannot rely on the explicit default implementation (`= default`)
as we support C++ 98.
At least GCC 7.3, with -O1 or -O2 (but not -O0 or -O3) generates
warnings with -Wnull-dereference when using yyformat: it fails to see
yyformat cannot be null.
Reported by Frank Heckenbach, https://savannah.gnu.org/patch/?9620.
* configure.ac: Use -Wnull-dereference if supported.
* data/glr.c, data/lalr1.cc, data/yacc.c: Define yyformat in such
a way that GCC cannot not see that yyformat is defined.
Using `default: abort();` also addresses the issue, but forces
the inclusion of `stdlib.h`, which we avoid.
Sometimes `inline` would be used in *.cc files on symbols that are not
exported (useless but harmless), and sometimes on exported symbols
such as the constructor of syntax_error (harmful: linking fails).
Reported several times, including:
- by Dennis T
http://lists.gnu.org/archive/html/bug-bison/2016-03/msg00002.html
- by Frank Heckenbach
https://savannah.gnu.org/patch/?9616
* data/c++.m4 (b4_inline): New: expands to `inline` or nothing.
Use it where appropriate.
* data/lalr1.cc: Use it where appropriate.
* tests/c++.at (Syntax error as exception): Put the scanner in another
compilation unit to exercise the constructor of syntax_error.
* data/lalr1.cc, doc/bison.texi, etc/bench.pl.in, examples/variant.yy,
* tests/actions.at, tests/atlocal.in, tests/c++.at, tests/headers.at,
* tests/local.at, tests/types.at:
Don't use std::endl, it flushes uselessly, and is considered bad
style.
Currently lalr1.cc makes an out-of-bound access when trying to read @1
in rules with an empty rhs (i.e., when there is no @1) that raises an
error (YYERROR).
glr.c already gracefully handles this by using @$ as initial location
for the errors. Let's do that in yacc.c and lalr1.cc.
* data/lalr1.cc, data/yacc.c: Use @$ to initialize the error location.
* tests/actions.at: Check that case.
This style appears to be more traditional, at least in C++.
For instance in the standard, [facets.examples].
There are occurrences using "unsigned int" too though.
* data/lalr1.cc, data/location.cc, data/stack.hh: here.
* origin/maint:
maint: post-release administrivia
version 3.0.4
gnulib: update
build: re-enable compiler warnings, and fix them
tests: c++: fix a C++03 conformance issue
tests: fix a title
c++: reserve 200 slots in the parser's stack
tests: be more robust to unrecognized synclines, and try to recognize xlc
tests: fix C++ conformance
build: fix some warnings
build: avoid infinite recursions on include_next
There are warnings (-Wextra) in generated C++ code:
ltlparse.cc: In member function 'ltlyy::parser::symbol_number_type
ltlyy::parser::by_state::type_get() const':
ltlparse.cc:452:33: warning: enumeral and non-enumeral type in
conditional expression
return state == empty_state ? empty_symbol : yystos_[state];
Reported by Alexandre Duret-Lutz.
It turns out that -Wall and -Wextra were disabled because of a stupid
typo.
* configure.ac: Fix the stupid typo.
* data/lalr1.cc, src/AnnotationList.c, src/InadequacyList.c,
* src/ielr.c, src/print.c, src/scan-code.l, src/symlist.c,
* src/symlist.h, src/symtab.c, src/tables.c, tests/actions.at,
* tests/calc.at, tests/cxx-type.at, tests/glr-regression.at,
* tests/named-refs.at, tests/torture.at:
Fix warnings, mostly issues about variables used only with assertions,
which are disabled with -DNDEBUG.
This is consistent with what is done with yacc.c and glr.c. Because
it also avoids that the stack needs to be resized very soon, it should
help keeping tests about destructors more reliable.
Indeed, if the stack is created too small, very soon the C++ library
needs to enlarge it, which means creating a new one, copying the
elements from the initial one onto it, and then destroy the elements
of the initial stack: that would be a spurious call to a destructor.
Reported by Thomas Jahns.
http://lists.gnu.org/archive/html/bug-bison/2015-01/msg00059.html
* data/stack.hh (stack::stack): Reserve 200 slots.
* tests/c++.at: Remove traces of stack expansions.
* origin/maint:
doc: minor fixes
gnulib: strtoul is considered obsolete and now useless
c++: avoid warnings when destructors don't use $$
maint: post-release administrivia
version 3.0.3
gnulib: update
* origin/maint:
tests: split a large test case into several smaller ones
package: a bit of trouble shooting indications
doc: liby's main arms the internationalization
bison: avoid warnings from static code analysis
c++: fix the use of destructors when variants are enabled
style: tests: simplify the handling of some C++ tests
c++: symbols can be empty, so use it
c++: variants: don't leak the lookahead in error recovery
c++: provide a means to clear symbols
c++: clean up the handling of empty symbols
c++: comment and style changes
c++: variants: comparing addresses of typeid.name() is undefined
c++: locations: complete the API and fix comments
build: do not clean figure sources in make clean
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.
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 ().
During error recovery, when discarding the lookeahead, we don't
destroy it, which is caught by parse.assert assertions.
Reported by Antonio Silva Correia.
With an analysis and suggested patch from Michel d'Hooge.
<http://savannah.gnu.org/support/?108481>
* tests/c++.at (Variants): Strengthen the test to try syntax errors
with discarded lookahead.
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.
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>
* data/variant.hh (yytname_): Replace with...
(yytypeid_): this.
There are no support for += between locations, and some comments are wrong.
Reported by Alexandre Duret-Lutz.
* data/location.cc: Fix.
* doc/bison.texi: Document.
* tests/c++.at: Check.
* origin/maint:
build: don't try to generate docs when cross-compiling
package: fix a reporter's name
%union: fix the support for named %union
package: bump to 2015
flex: don't trust YY_USER_INIT
yacc.c: fix broken union when api.value.type=union and %defines are used
doc: fix missing xref
gnulib: update
location: remove some ugly debugging code traces
build: use abort to pacify compiler errors
package: bump to 2014
doc: specify documentation encoding
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.
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.
* origin/maint: (43 commits)
maint: post-release administrivia
version 3.0.2
gnulib: update
output: do not generate source files when late errors are caught
output: record what generated files are source or report files
output: do not generate source files when early errors are caught
xml: also use "%empty" with html output
style: formatting changes
xml: also display %empty for empty right-hand sides
reports: display %empty in the generated pointed-rules
news: YYERROR vs variants
style: scope reduction in lalr.cc
lalr1.cc: formatting changes
lalr1.cc: fix the support of YYERROR with variants
tests: check $$'s destruction with variant, YYERROR, and no error recovery
tests: simplify useless obfuscation
skeletons: use better names when computing a "goto"
maint: post-release administrivia
version 3.0.1
aver: it is no longer "protected against NDEBUG"
...
Conflicts:
data/glr.c
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.
* 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.
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".