Commit Graph

5882 Commits

Author SHA1 Message Date
Akim Demaille
333bcd2ee3 build: fix support for --disable-dependency-tracking
Reported by Juan Manuel Guerrero.
https://lists.gnu.org/archive/html/bug-bison/2014-07/msg00000.html.

* examples/local.mk (%D%/extracted.stamp): Make sure the output
directory exists.
* examples/extexi (process): Likewise.
2018-09-09 15:14:20 +02:00
Akim Demaille
04705b9370 configure.ac: fix definition of NO_EXCEPTIONS_CXXFLAGS
* configure.ac: Always define it, not just when --enable-gcc-warnings
is passed.
2018-09-09 13:56:52 +02:00
Akim Demaille
79331541ae skeletons: style/comment changes
* data/c++.m4, data/c.m4, data/glr.c: Here.
2018-09-09 13:50:00 +02:00
Akim Demaille
d6fb1813ee variant: indent better the generated code
* data/variant.hh (b4_basic_symbol_constructor_declare)
(b4_basic_symbol_constructor_define): here.
2018-09-09 11:40:23 +02:00
Akim Demaille
7194099027 lalr1.cc: don't generate useless constructors when variant is used
This generates less code, which is nicer to read, but also takes less
chances with compilers such as G++ 4.8 that are too strict and check
"dead code" (templated code that is not instantiated).

* data/c++.m4 (b4_symbol_type_declare, b4_symbol_type_define): When
variants are used, don't generate code meant for non variants.
2018-09-09 11:40:23 +02:00
Akim Demaille
171b6bacb9 CI: Clang 6.0 is not available
But Clang 3.3 and 3.4 are.

* .travis.yml (addons): Remove, it appears to be ignore if the matrix
also defines it.
(matrix): Update.
2018-09-09 11:40:15 +02:00
Akim Demaille
e1c33f04d1 build: work around warnings in Flex
See ea0db44fed.  We also need to disable
the warning in the examples (but don't want to clutter the
documentation with such details).

* doc/bison.texi (scanner.ll): Disable Clang's -Wdocumentation.
While at it, hide the other kludges.
2018-09-08 12:13:29 +02:00
Akim Demaille
3c22b260b1 CI: more compiler configurations
* .travis.yml: here.
2018-09-08 08:03:09 +02:00
Akim Demaille
e5000890a4 configure: reveal the name of the Valgrind suppression file we use
* configure.ac: here.
* build-aux/Linux.valgrind (libstdcxx_init): New.
2018-09-08 08:02:42 +02:00
Akim Demaille
ea0db44fed build: work around warnings in Flex 2.5.35
That's the version on Ubuntu Precise.
See also 1dac131ec4.

* src/flex-scanner.h: Disable -Wdocumentation.
* doc/bison.texi: Turn off a warning triggered by Flex 2.6.4.
2018-09-08 07:53:08 +02:00
Akim Demaille
ec99c418a7 CI: show the version of the tools we use
We have failures on Flex output, which are probably related to an old
release.  Let's check.

    In file included from src/scan-code-c.c:3:
    src/scan-code.c:2198:21: error: empty paragraph passed to '@param' command
          [-Werror,-Wdocumentation]
     * @param line_number
       ~~~~~~~~~~~~~~~~~^

* .travis.yml: here.
2018-09-08 07:50:39 +02:00
Akim Demaille
a807cfa6eb CI: run more maintainer tests and show the logs
Running all these tests might be overkill: it is very long, and don't
need full portability checks.  Besides, some tests under Valgrind are
too slow and get killed by the CI (timeout of 10min without output).

* .travis.yml: here.
2018-09-08 07:48:15 +02:00
Akim Demaille
41c43ef3d7 CI: enable compiler warnings
* .travis.yml: here.
* README-hacking: We no longer aim at K&R C.
2018-09-08 07:01:50 +02:00
Akim Demaille
1dac131ec4 build: work around GCC warnings on Flex code
See ef98967ada.

* src/flex-scanner.h: Disable -Wnull-dereference for GCC 6+.
2018-09-06 21:28:24 +02:00
Akim Demaille
9268d9aceb tests: fix target naming convention
We have some maintainer-check-foo and some maintainer-foo-check.  Keep
only the former.

* tests/local.mk (maintainer-push-check, maintainer-xml-check)
(maintainer-release-check): Rename as...
(maintainer-check-push, maintainer-check-xml)
(maintainer-check-release): these.
2018-09-06 21:28:24 +02:00
Akim Demaille
bb5603c2f0 tests: fix variable naming convention
Most of our variables for C++ flags are named FOO_CXXFLAGS, not
CXXFLAGS_FOO.

* configure.ac, tests/atlocal.in, tests/calc.at
(NO_EXCEPTIONS_CXXFLAGS): Rename as...
(CXXFLAGS_NO_EXCEPTIONS): this.
2018-09-06 21:28:24 +02:00
Akim Demaille
2c29a70819 tests: fix maintainer-check-g++ make recipe
Clang++ issues warnings when it's used to compile C.  This make target
is precisely checking whether we can do that.

* configure.ac (NO_DEPRECATED_CXXFLAGS): New.
* tests/atlocal.in: Use it.
2018-09-06 21:28:24 +02:00
Akim Demaille
cf31256f9a tests: fix maintainer-check-valgrind make recipe
* tests/local.mk (maintainer-check-valgrind): Run the with Valgrind
when it's available, not the converse.
2018-09-06 21:28:24 +02:00
Akim Demaille
7132650bba CI: prepare for travis
* .travis.yml: New.
2018-09-06 13:51:36 +02:00
Akim Demaille
d908fb3f18 examples: beware of shell portability issues
This completes 2d7e743802.

Some shells don't grok "local var=`cmd`" very well: they need the rhs
to be quoted.

    ./examples/test: 72: local: you.,: bad variable name
    FAIL examples/variant.test (exit status: 2)

Reported by Étienne Renault.

* examples/test (run): Quote the values in 'local' assignments.
2018-09-06 13:51:19 +02:00
Akim Demaille
d023679818 tests: style changes
* tests/c++.at: Formatting changes.
Use 'using' to shorten the code.
2018-09-04 13:46:13 +02:00
Akim Demaille
d87c8ac79a tests: disable GCC7 warnings for some tests
With GCC7 we have warnings (false positive):

    x8.c: In function 'x8_parse':
    x8.c:1233:16: error: 'yylval' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             yylval = *yypushed_val;
             ~~~~~~~^~~~~~~~~~~~~~~
    x8.c: In function 'x8_pull_parse':
    x8.c:1233:16: error: 'yylval' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             yylval = *yypushed_val;
             ~~~~~~~^~~~~~~~~~~~~~~

See also 9645a2b20e.

* tests/local.at (AT_PUSH_IF): New.
(AT_BISON_OPTION_POPDEFS): Pop it, and pop AT_PURE_IF.
* tests/headers.at (Several parsers, Several parsers): Disable these
warnings when in push parser.
2018-09-02 18:15:55 +02:00
Akim Demaille
a7e46f6e41 C++: don't issue the definition of symbol_type when not used
Currently, in glr.cc, we emit the definitions of basic_symbol and
symbol_type, although there are not used.

* data/c++.m4 (b4_public_types_declare): Extract these definitions from
here, and move them...
(b4_symbol_type_declare): here.
(b4_public_types_declare): Also remove the definition of the symbol
constructors.
* data/lalr1.cc (b4_shared_declarations): Adjust: call
b4_symbol_type_declare and b4_symbol_constructor_declare.
2018-09-02 11:25:28 +02:00
Akim Demaille
2d7e743802 examples: beware of shell portability issues
Some shells don't grok `local var=$val` very well: they need the rhs
to be quoted.

    ./examples/test: 66: local: you.,: bad variable name
    FAIL examples/variant.test (exit status: 2)

Reported by Étienne Renault.

* examples/test (run): Quote the values in 'local' assignments.
2018-09-02 09:37:53 +02:00
Akim Demaille
50fb434689 C++: leave 'inline' on the definition, not the declaration
This is for consistency with the other uses of 'inline' in the C++
skeletons.  On examples/variant.yy, this change gives:

    --- examples/variant.hh	2018-08-31 07:16:57.214222580 +0200
    +++ examples/variant.hh	2018-08-31 07:19:52.285431997 +0200
    @@ -444,15 +444,15 @@
         typedef basic_symbol<by_type> symbol_type;

         // Symbol constructors declarations.
    -    static inline
    +    static
         symbol_type
         make_END_OF_FILE (const location_type& l);

    -    static inline
    +    static
         symbol_type
         make_TEXT (const ::std::string& v, const location_type& l);

    -    static inline
    +    static
         symbol_type
         make_NUMBER (const int& v, const location_type& l);

    @@ -945,19 +945,23 @@
         };
         return static_cast<token_type> (yytoken_number_[type]);
       }
    +
       // Implementation of make_symbol for each symbol type.
    +  inline
       parser::symbol_type
       parser::make_END_OF_FILE (const location_type& l)
       {
         return symbol_type (token::END_OF_FILE, l);
       }

    +  inline
       parser::symbol_type
       parser::make_TEXT (const ::std::string& v, const location_type& l)
       {
         return symbol_type (token::TEXT, v, l);
       }

    +  inline
       parser::symbol_type
       parser::make_NUMBER (const int& v, const location_type& l)
       {
    @@ -967,7 +971,7 @@

     } // yy
    -#line 971 "examples/variant.hh" // lalr1.cc:380
    +#line 975 "examples/variant.hh" // lalr1.cc:380

and no changes on variant.cc.

* data/c++.m4 (b4_public_types_define): Formatting changes.
* data/variant.hh (b4_symbol_value_template_, b4_symbol_constructor_declare_):
Move the 'inline' from declaration to implementation.
2018-08-31 07:25:57 +02:00
Akim Demaille
b5d4eb8913 c++: style changes
Instead of

    parser::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
      : super_type (that.state, that.location)
    {
      value = that.value;
    }

generate

    parser::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
      : super_type (that.state, that.value, that.location)
    {}

* data/lalr1.cc (stack_symbol_type): Improve the copy ctor, when not
using the variants.
(yypush_): Rename arguments for clarity.
2018-08-30 08:14:33 +02:00
Akim Demaille
2116ad3a28 c++: the assignment operator does not have to be const
* data/lalr1.cc (stack_symbol_type::operator=): Don't copy the
argument, move it.
2018-08-30 08:14:33 +02:00
Akim Demaille
15233a3728 tests: style changes
* tests/c++.at (C++ Variant-based Symbols): Rename as...
(C++ Variant-based Symbols Unit Tests): this.
Comment/style changes.
2018-08-30 08:14:21 +02:00
Akim Demaille
b476c143c0 maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2018-08-27 22:30:02 +02:00
Akim Demaille
2caaeba496 version 3.1
* NEWS: Record release date.
v3.1
2018-08-27 21:52:23 +02:00
Akim Demaille
95a65a3215 build: tabs are ok in a Makefile
* cfg.mk: TABs are ok in examples/calc++/Makefile.
2018-08-27 21:11:12 +02:00
Akim Demaille
33e523878b C++: make sure the generated header is self container
See the previous commit.

* data/lalr1.cc: Be sure to define YY_NULLPTR.
* tests/headers.at: Check the case that was failing.
2018-08-26 18:54:42 +02:00
Akim Demaille
2360e39906 tests: check that headers are sane
The header generated for variants with assertions but without
locations, is not self-contained.  Prepare a check for this.

* tests/headers.at (Sane headers): New, extracted from...
(Several parsers): here.
2018-08-26 18:51:11 +02:00
Akim Demaille
10082ac068 "C++: restore copy-constructor for stack_symbol_type
Benchmarks show that it is more efficient to keep this copy
constructor, rather than forcing the use of the default constructor
and then assignment.

This reverts commit 7ab25ad020.
2018-08-25 11:05:53 +02:00
Akim Demaille
de64159e7f examples: calc++: a Makefile and a README
* examples/calc++/Makefile, examples/calc++/README: New.
* examples/calc++/local.mk: Ship and install them.
* doc/bison.texi: Formatting changes.
2018-08-25 08:49:26 +02:00
Akim Demaille
280c40a350 gnulib: update 2018-08-25 07:47:25 +02:00
Jiahao Li
c1cf82f9c8 variant: fix uninitialized memory access in variant<>
Currently, in bison's C++ parser template (`lalr.cc`), the `variant<>`
struct's `build()` method uses placement-new in the form `new (...) T`
to initialize a variant type.  However, for POD variant types, this
will leave the memory space uninitialized.  If we subsequently tries
to `::move` into a variant object in such state, the call can trigger
clang's undefined behavior sanitizer due to accessing the
uninitialized memory.

https://lists.gnu.org/archive/html/bison-patches/2018-08/msg00098.html

* data/variant.hh (build): Always initialize the stored value.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
2018-08-25 07:25:05 +02:00
Akim Demaille
55947367c6 NEWS: update 2018-08-24 19:48:19 +02:00
Akim Demaille
b4e9eaefd5 examples: calc++: minor improvements
* doc/bison.texi (A Complete C++ Example): Prefer throw exceptions
from the scanner.
Show the invalid characters.
Since the scanner sends exceptions, it no longer needs to report
errors, so we can get rid of the driver's routine to report error,
do it in yyerror.
Use @group/@end group to improve rendering.
2018-08-24 19:40:36 +02:00
Akim Demaille
1a968edcb8 examples: calc++: make sure the file name in location is set
Reported by Hans Åberg.
http://lists.gnu.org/archive/html/bug-bison/2018-08/msg00039.html

* doc/bison.texi (A Complete C++ Example): Move the token's location
from the scanner to the driver.
2018-08-24 19:24:37 +02:00
Akim Demaille
82fa282a1b examples: calc++: remove prefixes
This example uses the calcxx_ prefix for each class.  That's uselessly
heavy.

* doc/bison.texi (A Complete C++ Example): Simplify the class names.
Since now 'driver' denotes the class, use 'drv' for the values.
Formatting changes.
2018-08-24 19:24:34 +02:00
Akim Demaille
e504c843c1 examples: fix the leading empty line
* examples/extexi: Really avoid the first empty line.
Remove useless `next`.
2018-08-23 19:16:11 +02:00
Akim Demaille
3fda8335bf examples: shorten the name of the calc++ files
* doc/bison.texi: Turn the calc++- prefix into calc++/.
* examples/extexi (%file_wanted): Replace with
(&file_wanted): this.
* examples/calc++/local.mk: Adjust.
2018-08-23 13:37:52 +02:00
Akim Demaille
9645a2b20e tests: disable -Wmaybe-uninitialized in some tests
On these tests, at -O2 and above, GCC 8 complains that yylval may be
uninitialized.  But it seems wrong: it is initialized.  Rather than
turning off the warning in the skeleton (hence possibility hiding
relevant warnings of user parsers), let's turn it off in the tests
only.

    163: parse.error=verbose and consistent errors:      FAILED (conflicts.at:625)
    165: parse.error=verbose and consistent errors: lr.default-reduction=consistent FAILED (conflicts.at:635)
    166: parse.error=verbose and consistent errors: lr.default-reduction=accepting FAILED (conflicts.at:641)
    167: parse.error=verbose and consistent errors: lr.type=canonical-lr FAILED (conflicts.at:645)
    168: parse.error=verbose and consistent errors: parse.lac=full FAILED (conflicts.at:650)
    169: parse.error=verbose and consistent errors: parse.lac=full lr.default-reduction=accepting FAILED (conflicts.at:655)

We get:

    input.c: In function 'yyparse':
    input.c:980:9: error: 'yylval' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
             ^~~~~~
    cc1: all warnings being treated as errors

See https://lists.gnu.org/archive/html/bison-patches/2018-08/msg00063.html.

* tests/conflicts.at (AT_CONSISTENT_ERRORS_CHECK): Disable
-Wmaybe-uninitialized.
2018-08-23 13:36:19 +02:00
Akim Demaille
7ff6b7bbca doc: clarify that the push parser object can be reused
Suggested by Rici Lake.
https://lists.gnu.org/archive/html/bug-bison/2018-08/msg00033.html

* doc/bison.texi: Complete description of the first node in the main
@menu.
(Push Decl): Remove the 'experimental' warnings about push parser.
Clarify that the push parser object can be reused in several parses.
2018-08-19 21:02:17 +02:00
Akim Demaille
44e76d801f lalr1.cc: support compilation with disabled support for exceptions
Reported by Brooks Moses <bmoses@google.com>
http://lists.gnu.org/archive/html/bison-patches/2018-02/msg00000.html

* data/lalr1.cc (YY_EXCEPTIONS): New.
Use it to disable try/catch clauses.

* doc/bison.texi (C++ Parser Interface): Document it.

* configure.ac (CXXFLAGS_NO_EXCEPTIONS): New.
* tests/atlocal.in: Receive it.
* tests/local.at (AT_FULL_COMPILE, AT_LANG_COMPILE):
Accept a new argument, extra compiler flags.
* tests/calc.at: Run the C++ calculator with exception support disabled.
2018-08-19 17:47:59 +02:00
Akim Demaille
32e0fd1a99 examples: add empty lines
Currently the examples are too dense, let's put empty lines where
'#line' would be issued.  And also remove some spurious empty
lines (remains from @group, @end group, etc.).

* examples/extexi: Do that.
* examples/local.mk (extexiFLAGS): Rename as...
(EXTEXIFLAGS): this.
2018-08-19 17:47:59 +02:00
Akim Demaille
b610f43f25 examples: check the variant example
* examples/mfcalc/local.mk, examples/rpcalc/local.mk: Define the
programs in a more natural order, source, preproc, then linker.

* examples/test: Be ready to work on programs that are not in
a subdir.
* examples/variant.test: New.
* examples/local.mk: Use it.
* examples/variant.yy: Don't use 0 for nullptr.
Use a more natural output for a list of string.
2018-08-19 17:47:59 +02:00
Akim Demaille
f348522005 C++: fix portability issue with MSVC 2017
Visual Studio issues a C4146 warning on '-static_cast<unsigned>(rhs)'.
The code is weird, probably to cope with INT_MIN.  Let's go back to
using std::max (whose header is still included in position.hh...) like
originally, but with the needed casts.

Reported by 長田偉伸, and with help from Rici Lake.

See also
http://lists.gnu.org/archive/html/bug-bison/2013-02/msg00000.html
and commit 75ae829984.

* data/location.cc (position::add_): Take min as an int.
Use std::max.
While here, get rid of a couple of useless inlines.
2018-08-18 18:07:43 +02:00
Akim Demaille
e866c476fd build: fix concurrent build failure
Reported by Dengke Du and Robert Yang.
https://lists.gnu.org/archive/html/bison-patches/2017-07/msg00000.html

* src/local.mk (src/yacc): Make sure the directory exists.
2018-08-18 15:37:14 +02:00