Commit Graph

5793 Commits

Author SHA1 Message Date
Akim Demaille
5649888686 build: use our own version of ax_check_link_flag
The message on configure is misleading:

    checking whether the linker accepts -std=c++11... yes
    checking whether the linker accepts -std=c++14... yes
    checking whether the linker accepts -std=c++17... no

It is the compiler that we check, not just the linker.

* m4/ax_check_link_flag.m4: Remove.
* m4/bison-check-compiler-flag.m4: New.
* m4/bison-cxx-std.m4: Use it.
2018-09-23 11:50:58 +02:00
Akim Demaille
e40a3eed34 build: fix Autoconf macros to check for C++ standard flags
* m4/bison-cxx-std.m4: Since now we link the program, we need a
program: main was missing and linking was failing.
2018-09-23 11:50:58 +02:00
Akim Demaille
6537a59c98 tests: fix a memory leak
This has been bugging me for while.  I was hard to reproduce: it
worked only on GNU/Linux, probably because libc++ implements the small
string optimization, while libstdc++ did not and actually allocated on
the heap for this small string.

See https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00110.html.

* tests/types.at (api.value.type): Do not provide a semantic value to
EOF.
2018-09-23 11:50:58 +02:00
Akim Demaille
154bc7ddac doc: work around Flex's use of 'register'
The CI uses an old version of Flex.
See 65fa634cdc.

* doc/bison.texi (calc++/scanner.ll): Here.
2018-09-22 19:40:37 +02:00
Akim Demaille
a990213582 timevar: don't declare getrusage if we don't use it
This fails on MinGW.
Reported by Simon Sobisch.
http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00058.html

* lib/timevar.c: Don't provide default prototypes for functions
we don't use.
2018-09-22 15:58:27 +02:00
Akim Demaille
9dfd46a5d5 timevar: get rid of a useless macro
* lib/timevar.h (timevar_report): Rename as...
(timevar_enabled): this.
* lib/timevar.c (TIMEVAR_ENABLE): Remove.
2018-09-22 15:58:27 +02:00
Akim Demaille
984d8cc72c timevar: introduce and use get_current_time
* lib/timevar.c: here.
Remove useless prototypes.
(timevar_accumulate): Be const correct.
2018-09-22 15:58:27 +02:00
Akim Demaille
896b2f75c5 timevar: rename get_time as set_to_current_time
* lib/timevar.c: here.
2018-09-22 15:58:27 +02:00
Akim Demaille
3ce67fa673 timevar: reduce scopes
* lib/timevar.c: here.
2018-09-22 15:58:27 +02:00
Akim Demaille
889dea0275 timevar: document in the header, not in the implementation
* lib/timevar.c: Move documentation from here...
* lib/timevar.h: to there.
2018-09-22 15:58:27 +02:00
Akim Demaille
ab3ec56ffe timevar: remove useless 'extern' for prototypes
* lib/timevar.h, lib/timevar.c: here.
2018-09-22 15:58:27 +02:00
Akim Demaille
c8da23c372 timevar: rename init_timevar as timevar_init
* lib/timevar.h, lib/timevar.c: here.
* src/main.c: Adjust.
2018-09-22 15:58:27 +02:00
Akim Demaille
69720f1231 timevar: we don't care about backward compatibility
* lib/timevar.h, lib/timevar.c (get_run_time, print_time): Remove.
2018-09-22 15:58:27 +02:00
Akim Demaille
100f8696c7 timevar: prefer #elif
* lib/timevar.c: Use #if/#elif to be clearer about mutually exclusive
cases.
Indent CPP nested directives.
2018-09-22 15:58:27 +02:00
Akim Demaille
8c6b06df1f timevar: assume ANSI C
Suggested by Bruno Haible.
https://lists.gnu.org/archive/html/bug-gnulib/2018-09/msg00102.html

* lib/timevar.c: Wow...  This was still KnR C!
2018-09-22 15:58:27 +02:00
Akim Demaille
6d9aafc5ad timevar: remove remains of GCC
* lib/timevar.h, lib/timevar.c: Rename the header guard.
Get rid of parts meant for GCC only.
2018-09-22 15:58:27 +02:00
Akim Demaille
878dc0a172 news: c++: move semantics 2018-09-22 14:52:13 +02:00
Akim Demaille
a874011e37 c++: issue a warning with a value is moved several times
Suggested by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00022.html

* src/scan-code.l (parse_ref): Check multiple occurrences of rhs
values.
* tests/c++.at (Multiple occurrences of $n and api.value.automove): New.
2018-09-22 11:22:31 +02:00
Akim Demaille
3eb9042a30 c++: introduce api.value.automove
Based on work by Frank Heckenbach.
See http://lists.gnu.org/archive/html/bug-bison/2018-04/msg00000.html
and http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00019.html.

* data/lalr1.cc (b4_rhs_value): Use YY_MOVE api.rhs.automove is set.
* doc/bison.texi (%define Summary): Document api.rhs.automove.
* examples/variant-11.yy: Use it.

* tests/local.at (AT_AUTOMOVE_IF): New.
* tests/c++.at (Variants): Check move semantics.
2018-09-22 09:49:46 +02:00
Akim Demaille
aa5de5728c tests: c++: use a custom string type
The forthcoming automove feature, to be properly checked, will require
that we can rely on the value of a moved-from string, which is not
something the C++ standard guarantees.  So introduce our own wrapper.

Suggested by Frank Heckenbach.
https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00111.html

* tests/c++.at (Variants): Introduce and use a new 'string' class.
2018-09-22 09:49:42 +02:00
Akim Demaille
21eeee46e9 tests: prepare a test for automove
The 'Variants' tests are well suited to check support for move, and in
particular for the forthcoming automove feature.  But the tests were
written to show the best practice in C++98, using swap:

    list "," item { std::swap ($$, $1); $$.push_back ($3); }

This cannot work with std::move.  So, make this example simpler, based
on regular assignment instead of swap, which is a regression for
C++98 (as the new traces show), but will be an improvement for modern
C++ with automove.

* tests/c++.at (Variants): Stop using swap.
We don't generate a header file, so remove the 'require' code section.
Adjust expectations.
2018-09-22 08:22:48 +02:00
Akim Demaille
db025a6fb7 style: reduce scopes in gram.c
* src/gram.c: here.
2018-09-20 21:19:55 +02:00
Akim Demaille
ca822faeec style: reduce scopes in reduce.c
* src/reduce.c: Here.
2018-09-20 21:19:55 +02:00
Akim Demaille
ae915ab8e7 gnulib: update 2018-09-20 07:06:52 +02:00
Akim Demaille
27630864e7 build: work around ICC's limitations
Several types of failures.  First, unable to pass the file name
properly to the linker.

    ./synclines.at:416: $CC $CFLAGS $CPPFLAGS  $LDFLAGS -o \"\\\"\" \"\\\"\".c $LIBS
    stderr:
    ld: cannot open output file "/"": No such file or directory
    stdout:

Unable to save under such a file name.

    ./synclines.at:421: $CXX $CXXFLAGS $CPPFLAGS -c $LDFLAGS -o \"\\\"\" \"\\\"\".cc $LIBS
    stderr:
    error: can't open file "/"" for write
    compilation aborted for "\"".cc (code 1)

Spurious output because of warning flags is failed to reject as an
error during configure:

    ./headers.at:343: $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS c-only.o cxx-only.o -o c-and-cxx ||
              exit 77
    --- /dev/null	2018-09-18 21:21:37.745649000 +0000
    +++ /home/travis/build/akimd/bison/tests/testsuite.dir/at-groups/222/stderr	2018-09-18 21:28:17.291919519 +0000
    @@ -0,0 +1,7 @@
    +icpc: command line warning #10006: ignoring unknown option '-Wcast-align'
    +icpc: command line warning #10006: ignoring unknown option '-fparse-all-comments'
    +icpc: command line warning #10006: ignoring unknown option '-Wdocumentation'
    +icpc: command line warning #10006: ignoring unknown option '-Wnull-dereference'
    +icpc: command line warning #10006: ignoring unknown option '-Wnoexcept'
    +icpc: command line warning #10006: ignoring unknown option '-fno-color-diagnostics'
    +icpc: command line warning #10006: ignoring unknown option '-Wno-keyword-macro'
    stdout:

* tests/local.at (AT_SKIP_IF_CANNOT_LINK_C_AND_CXX): Also ignore
stderr, as with ICC we get
* tests/synclines.at (syncline escapes): Don't link the output.
2018-09-20 06:30:46 +02:00
Akim Demaille
857be0e10f doc: fix typo
Introduced in the previous commit.

* doc/bison.texi: here.
2018-09-19 22:13:57 +02:00
Akim Demaille
bbfa419b89 style: use midrule only, not mid-rule
The code was already using midrule only, never mid_rule.  This is
simpler to remember, and matches a similar change we made from
look-ahead to lookahead.

* NEWS, doc/bison.texi, src/reader.c, src/scan-code.h, src/scan-code.l
* tests/actions.at, tests/c++.at, tests/existing.at: here.
2018-09-19 22:09:53 +02:00
Akim Demaille
b7613423ce style: use _foo for private macros, not foo_
We use both styles, let's stick to a single one.  Autoconf uses the
prefix one, let's do the same.

* data/bison.m4, data/c++.m4, data/c-like.m4, data/lalr1.cc,
* data/variant.hh, data/yacc.c: Rename all the b4_*_ macros
as _b4_*.
2018-09-19 20:42:43 +02:00
Akim Demaille
49dc1b5bf1 build: don't accept a broken standard lib for C++
On the CI, we had failures such as:

    ./c++.at:401:  $PREPARSER ./list
    stderr:
    ./list: error while loading shared libraries: libc++.so.1:
            cannot open shared object file: No such file or directory

because we accepted `-std=c++ -stdlib=libc++` although libc++ is not
installed on the machine.

* m4/ax_check_compile_flag.m4 (AX_CHECK_COMPILE_FLAG): Rewrite as...
* m4/bison-check-compile-flag.m4 (BISON_CHECK_COMPILE_FLAG): this, so
that we use AC_LINK_IFELSE to check the compiler (and its std lib)
instead of AC_COMPILE_IFELSE.
2018-09-19 06:02:41 +02:00
Paul Eggert
f475105c2f doc: document older compiler issues
* doc/bison.texi (Compiler Requirements for GLR):
Rename from Compiler Requirements.
(I can't build Bison): Add FAQ for older compilers.
2018-09-18 13:17:46 -07:00
Akim Demaille
a60a9e3071 glr.c: work around ICC limitations
The CI is littered with

    #                             -*- compilation -*-
    423. regression.at:907: testing Dancer %glr-parser ...
    ./regression.at:907: bison -fno-caret -o dancer.c dancer.y
    ./regression.at:907: $BISON_C_WORKS
    stderr:
    stdout:
    ./regression.at:907: $CC $CFLAGS $CPPFLAGS  $LDFLAGS -o dancer dancer.c $LIBS
    stderr:
    icc: command line warning #10006: ignoring unknown option '-Wcast-align'
    icc: command line warning #10006: ignoring unknown option '-fparse-all-comments'
    icc: command line warning #10006: ignoring unknown option '-Wdocumentation'
    icc: command line warning #10006: ignoring unknown option '-Wnull-dereference'
    icc: command line warning #10006: ignoring unknown option '-Wbad-function-cast'
    icc: command line warning #10006: ignoring unknown option '-fno-color-diagnostics'
    icc: command line warning #10006: ignoring unknown option '-Wno-keyword-macro'
    dancer.c(755): error #1628: function declared with "noreturn" does return
      }
      ^

    dancer.c(761): error #1628: function declared with "noreturn" does return
      }
      ^

    compilation aborted for dancer.c (code 2)

ICC sees that `longjmp(buf, 1);` does not return, it sees that
`abort();` does not either, but fails to see it for
`longjmp(buf, 1); abort();`

* data/glr.c (YYLONGJMP): Be even clearer on the fact this does not
return.
2018-09-18 17:21:13 +02:00
Akim Demaille
c53d599df4 TODO: more 2018-09-18 13:21:39 +02:00
Akim Demaille
9458250968 CI: change strategy to pass CXXFLAGS and the like
Putting them in the env is useless.  We don't want to pass
`CPPFLAGS="$CPPFLAGS"` to configure, as it means "set it to nothing"
when $CPPFLAGS is not set, which is not what we want.

This correctly started to use libc++, but it is not installed on the
Ubuntu.  We will see later if we can use it.

* .travis.yml: Define CONFIGUREFLAGS, and pass it to configure.
2018-09-18 13:21:39 +02:00
Akim Demaille
8cbc235723 CI: also use GCC 4.7 and 4.8
* .travis.yml (matrix): here.
2018-09-18 13:21:39 +02:00
Akim Demaille
9a377eb0a8 CI: name the items of the matrix
* .travis.yml: here.
2018-09-18 13:21:38 +02:00
Akim Demaille
09aa05d89c CI: also check with ICC
* build-aux/install-icc.sh: New.
* .travis.yml (icc): New.
Use -k to get as many errors as possible from the start.
* src/complain.c (warnings_types): Use a more precise type.
2018-09-18 13:21:38 +02:00
Akim Demaille
2b7dca1c86 CI: be sure to exit on failures
a807cfa6eb completely broke the whole
point of having a CI: we always exit with success!
2018-09-18 13:21:38 +02:00
Akim Demaille
3367d8dd5c build: strengthen the C++ standard flag test
On the CI, we have this spurious failure with clang 3.9 with
-std=c++17:

    In file included from list.y:23:
    In file included from /usr/include/c++/4.8/iostream:39:
    In file included from /usr/include/c++/4.8/ostream:38:
    In file included from /usr/include/c++/4.8/ios:42:
    In file included from /usr/include/c++/4.8/bits/ios_base.h:41:
    In file included from /usr/include/c++/4.8/bits/locale_classes.h:40:
    In file included from /usr/include/c++/4.8/string:52:
    In file included from /usr/include/c++/4.8/bits/basic_string.h:2815:
    In file included from /usr/include/c++/4.8/ext/string_conversions.h:43:
    /usr/include/c++/4.8/cstdio:120:11: error: no member named 'gets' in the global namespace
      using ::gets;
            ~~^

This shows that our test, based on gl_WARN_ADD, is a joke.  We have to
really check for at least a bit of C++.

* m4/ax_check_compile_flag.m4, m4/bison-cxx-std.m4: New.
* configure.ac: Use them to make sure the compiler actually works.
2018-09-18 13:21:38 +02:00
Akim Demaille
8da0cef821 tests: fix memory leak
This was reported by ASAN on the CI.

* tests/types.at (api.value.type): Don't set a semantic value to EOF.
2018-09-18 13:21:38 +02:00
Akim Demaille
fb1e27cf47 glr.c: prefer true/false to 1/0 in C++
* data/glr.c: here.
2018-09-18 13:21:38 +02:00
Akim Demaille
65fa634cdc doc: work around Flex's use of 'register'
The CI uses an old version of Flex.

* doc/bison.texi (calc++/scanner.ll): Here.
2018-09-18 13:21:38 +02:00
Akim Demaille
7c64b1f4ff tests: fight G++ warnings about zero as null pointer constant
In C++ pre C++11 it is standard practice to use 0 for the null pointer.
But GCC pre 8 -std=c++98 with -Wzero-as-null-pointer-constant warns about
this.

So disable -Wzero-as-null-pointer-constant when compiling C++ pre 11.
Let's do this in AT_DATA_SOURCE_PROLOGUE (which is pasted on top of
all the test grammar files).  Unfortunately, that shifts all the
locations in the expected error messages, which would be too noisy.
Instead, let's introduce testsuite.h, which can vary in length, and
include it in AT_DATA_SOURCE_PROLOGUE.

* tests/testsuite.h: New.
Disable -Wzero-as-null-pointer-constant's warning with GCC pre 8,
C++ pre 11.
* tests/local.at (AT_DATA_SOURCE_PROLOGUE): Use it.
* tests/atlocal.in (CPPFLAGS): Find it.
* tests/local.mk: Ship it.
* data/c.m4 (YY_NULLPTR): Prefer ((void*)0) to 0 in C.
2018-09-18 13:21:38 +02:00
Akim Demaille
9611baf855 CI: make sure git describe works
For some reasons, the checkout on travis may not have any tags, so
`git describe` fails, so bootstrap fails.

* .travis.yml: If git describe fails, install some tag.
2018-09-18 13:21:38 +02:00
Akim Demaille
2559f4cec5 CI: install Doxygen
* .travis.yml: here, so that its tests are not skipped.
Remove valgrind: it's too expensive on the CI, and asan does the job.
2018-09-18 13:21:38 +02:00
Akim Demaille
d4fbda2a94 style: prefer %D% in Automake files
* tests/local.mk: Prefer %D%/ to tests/.
2018-09-16 16:20:39 +02:00
Akim Demaille
84dcd7991b style: reduce scopes in complain.c 2018-09-15 08:28:02 +02:00
Akim Demaille
50910389c9 style: reduce scopes in tables.c
* src/tables.c: here.
* src/state.h: Formatting changes.
2018-09-15 07:59:57 +02:00
Akim Demaille
6cc69f4d14 style: reduce scopes in graphviz.c 2018-09-15 07:20:49 +02:00
Akim Demaille
46532a9d3b style: reduce scopes in LR0.c 2018-09-15 07:20:49 +02:00
Akim Demaille
5603f0bdf2 style: reduce scopes in print_graph.c
* src/print_graph.c: here.
2018-09-15 07:20:49 +02:00