Commit Graph

7230 Commits

Author SHA1 Message Date
Vincent Imbimbo
b5e0351c3e cex: fix lssi leaks
* src/lssi.c (shortest_path_from_start): Free the root of
shortest_path_from_start search.
Free eligible bitset.
2020-05-22 08:45:44 +02:00
Vincent Imbimbo
150b2318ed cex: fix parse state leaks
* src/parse_simulation.c: Fix bug in parse_state_free.
Free new_root when simulate_reduction generates zero states.

* src/parse-simulation.c, src/parse-simulation.h
(parse_state_list, parse_state_list_append): New.
* src/parse-simulation.c, src/parse-simulation.h,
* src/counterexample.c: Replace all uses of lists of parse states and
appends to parse_state_lists with the new API.
2020-05-22 08:45:44 +02:00
Vincent Imbimbo
35c4a8e65e cex: derivation reference counting
* src/derivation.h, src/derivation.c: Make derivation struct opaque.
Add derivation_list type for clarity.
(derivation_list_new): New.
(derivation_list_append): New.
(derivation_list_prepend): New.
(derivation_new_leaf): New constructor for derivations with no
children.
* src/counterexample.c, src/parse-simulation.c,
* src/parse-simulation.h: Replace uses of gl_list_t containing
derivations with derivation_list and its API.
Replace calls of dervation_new using null children with
derivation_new_leaf.
* src/parse-simulation.c: replace ps_chunk and its API with typed
versions si_chunk and deriv_chunk.
* src/parse-simlation.h, src/parse-simulation.c: Remove
parse_state_retain_deriv in favor of derivation reference counting.
* src/counterexample.c: Remove search_state_retain_deriv.
2020-05-22 08:45:44 +02:00
Akim Demaille
fc39ccab6b cex: style changes in parse-simulation
* src/parse-simulation.c: Formatting changes.
(parse_state_list_new): New.
Use it.
2020-05-22 08:45:44 +02:00
Akim Demaille
9a33fb9317 cex: style: prefer res for returned value
* src/lssi.c, src/parse-simulation.c: here.
2020-05-22 08:45:44 +02:00
Akim Demaille
866bc6a49f cex: fix memory leaks when there are conflicts
* src/counterexample.c (production_step, reduction_step): Release
memory of temporary objects.
2020-05-22 08:45:43 +02:00
Akim Demaille
e8619330e8 cex: be sure to always reclaim memory put in hashes
One call to hash_initialize did not provide a function to free memory.

* src/state-item.c (hash_pair_table_create): New.
Use it.
2020-05-22 08:45:43 +02:00
Akim Demaille
193dc86965 cex: properly reclaim hash's allocated memory
* src/state-item.c: Use hash_free where appropriate.
2020-05-22 08:45:43 +02:00
Akim Demaille
51fa2ab0a2 cex: avoid gratuitous heap allocations
There's no need to go for the heap when using gnulib's hash module.

* src/state-item.c (hash_pair_lookup, hash_pair_remove,
state_sym_lookup): Use the heap Luke.
That removes a leak from hash_pair_lookup.
(init_prods): Use hash_pair_insert instead of duplicating it.
2020-05-22 08:45:43 +02:00
Vincent Imbimbo
2d8c3edbf8 cex: fix leaks
* src/state-item.c: Various functions were using heap allocated locals
and not freeing them.
2020-05-22 08:45:43 +02:00
Akim Demaille
4590071287 style: use hash_xinsert
* gnulib: Update to get hash_xinsert.
Use it where appropriate.
2020-05-22 08:45:43 +02:00
Akim Demaille
ac3b6c18a5 cex: style changes in state-item
* src/state-item.h, src/state-item.c (state_item): Make the state
const.
(state_item_set): Make it clearer that it works in the state_items
global array.
2020-05-22 08:45:43 +02:00
Akim Demaille
f3ef847539 cex: stylistic changes
* src/counterexample.c: Use 'res' as a variable name for returned
value, as elsewhere.
Avoid uninitialized variables, especially pointers.
Avoid assignment where possible.
2020-05-22 08:45:43 +02:00
Akim Demaille
16f2353723 cex: avoid uninitialized variables
* src/counterexample.c (item_rule_bounds): Split into...
(item_rule_start, item_rule_end): these.
Adjust dependencies.
* src/conflicts.c (find_state_item_number): New.
Use it to avoid uninitialized variables.
2020-05-22 08:45:29 +02:00
Akim Demaille
da5317cc9d cex: isolate missing API from gl_list
* src/counterexample.c (list_get_end): New.
Use it.
Reduce scopes.
2020-05-22 07:52:27 +02:00
Akim Demaille
e0cb91a922 cex: tests: be robust to variations in time limit reports
The CI has "failures" such as (253, "Null nonterminals"):

    @@ -21,7 +21,7 @@
     3:    3 b: . %empty
     3:    4 c: . %empty
     On Symbols: {A,}
    -time limit exceeded: 6.000000
    +time limit exceeded: 11.000000
     First  Example c  •  c  A  A  $end
     First  derivation  $accept ::=[ a ::=[ c  d ::=[ a ::=[ b ::=[ • ]  d ::=[ c  A  A ] ] ] ]  $end ]
     Second Example c  •  A  $end

* tests/counterexample.at (AT_BISON_CHECK_CEX): New.
Use it to neutralize differences in timeout values.
2020-05-22 07:52:27 +02:00
Vincent Imbimbo
482b370540 cex: fix stack overflow
* src/parse-simulation.c: Replace reference counting with
parse_state_retain everywhere.
(free_parse_state): Make this function iterative instead of
recursive. Long parse_state chains were causing stack exhaustion.

* tests/counterexample.at: Fix expectations.
2020-05-22 07:52:27 +02:00
Vincent Imbimbo
66283fb625 cex: fix crash from zombie result
Fixes the SEGV in test 247 (counterexample.at:195): "S/R after first
token".

* src/counterexample.c: here.
* tests/counterexample.at: Fix expectations.
2020-05-22 07:52:27 +02:00
Akim Demaille
93c849ef0d cex: fixes, and enable tests
* src/counterexample.c, src/derivation.c:
Do not output diagnostics on stdout, that's the job of stderr, and the
testsuite heavily depend on this.
Do not leave trailing spaces in the output.
* tests/counterexample.at: Use AT_KEYWORDS.
Specify the expected outputs.
* tests/local.mk: Add counterexample.at.
2020-05-22 07:52:27 +02:00
Akim Demaille
6279945003 cex: fix a crash
* src/state-item.c (init_state_items): If the rule has no reductions
at all, don't read at all in its list of reduced rules.
2020-05-22 07:52:27 +02:00
Vincent Imbimbo
dcb6c972a2 cex: add tests
* tests/counterexample.at: New.
2020-05-22 07:52:27 +02:00
Vincent Imbimbo
af0441cfd2 cex: bind counterexample generation
* src/complain.h, src/complain.c: Add support for -Wcounterexample.
* src/conflicts.c (report_counterexamples): New.
(rule_conflicts_print): Use it when -Wcounterexample is given.
* src/getargs.h, src/getargs.c: Add support for --trace=cex.
* src/main.c (main): Init and deinit counterexample generation.
2020-05-22 07:52:27 +02:00
Vincent Imbimbo
bbb63b1ca9 cex: introduce counterexample search
* src/counterexample.h, src/counterexample.c: New.
2020-05-22 07:52:27 +02:00
Vincent Imbimbo
ac54d19eba cex: introduce the parse simulator
* src/derivation.h, src/derivation.c,
* src/parse-simulation.h, src/parse-simulation.c: New.
2020-05-22 07:52:27 +02:00
Vincent Imbimbo
5807dd9279 cex: add support for state-item pair graph generation
* src/lssi.h, src/lssi.c, src/state-item.h, src/state-item.c: New.
2020-05-22 07:52:27 +02:00
Akim Demaille
94bfdf3b4b cex: add gnulib dependencies
* bootstrap.conf (gnulib_modules): Add linked-list.
2020-05-22 07:52:27 +02:00
Thomas Petazzoni
ed7d5c2b5b src: make path to m4 relocatable
Commit a4ede8f85b ("package: make bison
a relocatable package") made Bison relocatable, but in fact it still
contains one absolute reference: the M4 variable, which points to the
M4 program. Let's fix that by using relocate(), see if an M4 binary is
available at the relocated location, and otherwise fallback to the
original M4 location.

See https://lists.gnu.org/r/bison-patches/2020-05/msg00078.html,
and https://lists.gnu.org/r/bison-patches/2020-05/msg00087.html.

* src/files.h, src/files.c (m4path): New.
* src/output.c: Use it.
2020-05-20 08:09:27 +02:00
Akim Demaille
1ce02e13c3 CI: fix PPC recipe 2020-05-17 11:01:19 +02:00
Akim Demaille
8ef0b12eb7 Merge branch 'maint'
* upstream/maint:
  maint: post-release administrivia
  version 3.6.2
  tests: improve update-test
  CI: add GCC 10 and Clang 10
  fix: do not emit nested comments
  todo: update
  examples: use markdown hyperlinks
  tests: don't use == to compare const char *...
  gnulib: update
2020-05-17 09:16:51 +02:00
Akim Demaille
e6d83116ae c: more fixes for _Noreturn
The previous fix was insufficient.

    tests/types.at:366: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o test test.cc $LIBS
    ++ ccache clang++-mp-9.0 -Qunused-arguments -ggdb -Wall -Wextra -Wcast-align -Wchar-subscripts -fparse-all-comments -Wdocumentation -Wformat -Wimplicit-fallthrough -Wnull-dereference -Wno-sign-compare -Wno-tautological-constant-out-of-range-compare -Wpointer-arith -Wshadow -Wwrite-strings -Wextra-semi -Wold-style-cast -Wundefined-func-template -Wweak-vtables -Wunreachable-code -Wundef -pedantic -Wconversion -Wdeprecated -Wsign-compare -Wsign-conversion -Wtautological-constant-out-of-range-compare -fno-color-diagnostics -Wno-keyword-macro -Werror -std=c++98 -I/Users/akim/src/gnu/bison/tests -isystem /opt/gostai/include -isystem /opt/local/include -L/opt/gostai/lib -L/opt/local/lib -o test test.cc /Users/akim/src/gnu/bison/_build/c9d/lib/libbison.a -lintl -Wl,-framework -Wl,CoreFoundation
    stderr:
    test.cc:955:1: error: _Noreturn functions are a C11-specific feature [-Werror,-Wc11-extensions]
    _Noreturn static void
    ^
    test.cc:963:1: error: _Noreturn functions are a C11-specific feature [-Werror,-Wc11-extensions]
    _Noreturn static void
    ^
    2 errors generated.

* data/skeletons/c.m4 (b4_attribute_define): Do not use _Noreturn at
all in C++, clang or not.
2020-05-17 09:16:41 +02:00
Akim Demaille
4d9fa28ba8 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-05-17 08:55:47 +02:00
Akim Demaille
a100a3c4c1 version 3.6.2
* NEWS: Record release date.
v3.6.2
2020-05-17 08:30:46 +02:00
Akim Demaille
b18ceb50f1 tests: improve update-test
* build-aux/update-test: When given a directory, use the testsuite.log
which it contains.
Do not accept empty "from"s, as substituting the empty string with
something is rarely a good idea.
2020-05-17 08:28:12 +02:00
Akim Demaille
ff4d67ede8 CI: add GCC 10 and Clang 10
* .travis.yml: Here.
* tests/input.at, tests/regression.at: Beware of clang's -Wdocumentation.
2020-05-17 08:28:12 +02:00
Akim Demaille
465babb635 fix: do not emit nested comments
With input such as

    %token<fl> yVL_CLOCK "/*verilator sc_clock*/"

we generate

    yVL_CLOCK = 610,      /* "/*verilator sc_clock*/"  */

which is invalid since the comment will actually be closed on the
first "*/".  Let's turn "*/" into "*\/" to avoid this.  But GCC will
also warn about "/*" inside a comment, so let's "escape" it too.

Reported by Huang Rui.
https://github.com/akimd/bison/issues/38

* data/skeletons/c-like.m4 (_b4_comment): Escape comment delimiters in
comments.
* tests/input.at (Torturing the Scanner): Check thes cases.
* tests/m4.at: New.
2020-05-17 08:28:12 +02:00
Akim Demaille
22c3839168 c: restore definition of _Noreturn as [[noreturn]] in C++
c.m4 contains a definition of _Noreturn which is modeled after
gnulib's lib/_Noreturn.h.  The latter was recently
changed (b61bf2f0e8) to not using
[[noreturn]] at all, because the uses of _Noreturn in gnulib are
sometimes incompatible with the rules of [[noreturn]].

As a result glr.cc started to use _Noreturn in C++, which clang
refuses (all the glr.cc tests currently fail with Clang++).

* data/skeletons/c.m4 (b4_attribute_define): Restore the definition of
_Noreturn as [[noreturn]] in modern C++.
The generated code uses _Noreturn in places where [[noreturn]] is
valid.
2020-05-16 17:29:38 +02:00
Akim Demaille
4619b32dc0 examples: don't promote unchecked function calls
* etc/bench.pl.in, examples/c/bistromathic/parse.y,
* examples/c/calc/calc.y, examples/c/pushcalc/calc.y: Check scanf's
return value.
* doc/bison.texi: Likewise, but only for the second example, to avoid
cluttering the very simple case.
2020-05-16 14:39:57 +02:00
Akim Demaille
ad921890c1 gnulib: update 2020-05-16 14:39:57 +02:00
Akim Demaille
6a28e6d412 todo: update 2020-05-15 07:18:15 +02:00
Akim Demaille
f4495da337 examples: use markdown hyperlinks
* examples/c++/README.md, examples/c++/calc++/README.md,
* examples/c/README.md: here.
2020-05-14 07:26:55 +02:00
Akim Demaille
dbaed0bbf2 tests: don't use == to compare const char *...
Reported by Dagobert Michelsen.
https://lists.gnu.org/r/bug-bison/2020-05/msg00091.html

* tests/c++.at: here.
2020-05-14 07:26:34 +02:00
Akim Demaille
78c7fb6460 gnulib: update 2020-05-14 07:25:09 +02:00
Akim Demaille
14ce500508 tests: improve update-test
* build-aux/update-test: When given a directory, use the testsuite.log
which it contains.
Do not accept empty "from"s, as substituting the empty string with
something is rarely a good idea.
2020-05-13 19:48:03 +02:00
Akim Demaille
acba58ac59 Merge branch maint
* maint:
  news: update
  maint: post-release administrivia
  version 3.6.1
  c++: style: reorder generated code
  c++: provide yy::parser::symbol_type::name
  c++: make parser::symbol_name public
  examples: beware of ~/.inputrc
  build: also provide lzip compressed tarballs
  style: minor fixes
  yacc.c: restore ansi-c compatibility
2020-05-10 17:33:12 +02:00
Akim Demaille
da29809969 news: update 2020-05-10 17:32:28 +02:00
Akim Demaille
87e4895189 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2020-05-10 14:47:51 +02:00
Akim Demaille
01e3f45f83 version 3.6.1
* NEWS: Record release date.
v3.6.1
2020-05-10 14:28:24 +02:00
Akim Demaille
9c21da3363 bench: add support to randomize the order of execution
It's amazing how much the order matters.  To a point that many of
these benches are meaningless.  For instance (some of the benches
where run with `make -C benches/latest rand
BENCHFLAGS=--benchmark_min_time=3`):

    compiler: g++ -std=c++11 -O2
      0. %define nofinal
      1.
    --------------------------------------------------
    Benchmark           Time           CPU Iterations
    --------------------------------------------------
    BM_y0            1543 ns       1541 ns     441660
    BM_y1            1521 ns       1520 ns     456535
    --------------------------------------------------
    BM_y0            1531 ns       1530 ns     440584
    BM_y1            1512 ns       1511 ns     457591
    --------------------------------------------------
    BM_y0            1539 ns       1538 ns    2749330
    BM_y1            1516 ns       1515 ns    2771500
    --------------------------------------------------
    BM_y0            1571 ns       1570 ns    2600782
    BM_y1            1542 ns       1541 ns    2708349
    --------------------------------------------------
    BM_y0            1530 ns       1529 ns    2670363
    BM_y1            1519 ns       1518 ns    2764096

    --------------------------------------------------
    Benchmark           Time           CPU Iterations
    --------------------------------------------------
    BM_y1            1529 ns       1528 ns     451937
    BM_y0            1508 ns       1507 ns     453944
    --------------------------------------------------
    BM_y1            1525 ns       1524 ns    2750684
    BM_y0            1516 ns       1515 ns    2794034
    --------------------------------------------------
    BM_y1            1526 ns       1525 ns    2749620
    BM_y0            1515 ns       1514 ns    2808112
    --------------------------------------------------
    BM_y1            1524 ns       1523 ns    4475844
    BM_y0            1502 ns       1501 ns    4611665

* etc/bench.pl.in: here.
2020-05-10 11:51:46 +02:00
Akim Demaille
febf6115a0 bench: use a Makefile
This makes it much easier to toy with the benchs.

* etc/bench.pl.in: Generate a Makefile instead of directly compiling
the files.
2020-05-10 11:51:41 +02:00
Akim Demaille
11b5bac7bf examples: use markdown hyperlinks
* examples/c++/README.md, examples/c++/calc++/README.md,
* examples/c/README.md: here.
2020-05-10 11:51:17 +02:00