summaryrefslogtreecommitdiff
path: root/tests/headers.at
Commit message (Collapse)AuthorAgeFilesLines
* package: bump copyrights to 2022Paul Eggert2022-01-151-1/+1
| | | | Run "make update-copyright".
* tests: Apple clang issues warning on C++11 featuresAkim Demaille2021-09-251-0/+4
| | | | | | | | | | | | | | | | | | | | $ cat /tmp/foo.cc using foo = int; foo f; $ clang++ -Wc++11-extensions -c /tmp/foo.cc /tmp/foo.cc:1:13: warning: alias declarations are a C++11 extension [-Wc++11-extensions] using foo = int; ^ 1 warning generated. $ clang++ --version Apple clang version 11.0.0 (clang-1100.0.33.17) Target: x86_64-apple-darwin18.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin * tests/local.at (AT_COMPILE_CXX): Make sure -std=c++11 is passed when running glr2.cc. It may be overridden by another flag in CXXFLAGS afterwards.
* glr2.cc: check linking conflictsAkim Demaille2021-09-121-1/+6
| | | | * tests/headers.at (Several Headers): Link two glr2.cc parsers.
* glr2.cc: don't publish YY_EXCEPTIONSAkim Demaille2021-09-121-2/+6
| | | | | | | | We don't need them in the header file. * data/skeletons/glr2.cc (YY_EXCEPTIONS): Define only in the implementation file. * tests/headers.at (Several Parsers): Also check glr2.cc.
* c++: issue a compile-time warning when #define YYSTYPE is usedAkim Demaille2021-02-011-7/+10
| | | | | | | | | | | | | | | | | | | | | | Using #define YYSTYPE has always been strongly discouraged in C++. Macros are dangerous and can result in subtle bugs. https://lists.gnu.org/r/bug-bison/2020-12/msg00007.html Maybe some people are currently using #define YYSTYPE. Instead of dropping support right now, first issue a warning. Bison can "see" if YYDEBUG is defined (it could even be on the command line), only the compiler knows. Unfortunately `#warning` is non-portable, and actually GCC even dies on it when `-pedantic` is enabled. So we need to use `#pragma message`. We must make it conditional as some compilers might not support it, but it doesn't matter if only _some_ compilers emit the warning: it should be enough to catch the attention of the developers. * data/skeletons/c++.m4: Issue a warning when the user defined YYSTYPE. * tests/actions.at: Don't #define YYSTYPE. * tests/headers.at (Several parsers): Ignore the YYSTYPE in the warning.
* Update URLs to prefer https: to http:Paul Eggert2021-01-291-1/+1
| | | | Also, fix a few http: URLs that were no longer working.
* package: bump copyrights to 2021Akim Demaille2021-01-161-1/+1
| | | | Run 'make update-copyright'.
* style: YYUSE is private, make it YY_USEAkim Demaille2021-01-031-2/+2
| | | | | | | | | | This macro is not exposed to users, make start it with 'YY_'. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.c, * data/skeletons/glr.cc, data/skeletons/glr2.cc, data/skeletons/lalr1.cc, * src/parse-gram.c, tests/actions.at, tests/c++.at, tests/headers.at, * tests/local.at (YYUSE): Rename as... (YY_USE): this.
* Merge branch 'maint'Akim Demaille2020-11-131-9/+27
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * maint: c++: shorten the assertions that check whether tokens are correct c++: don't glue functions together lalr1.cc: YY_ASSERT should use api.prefix c++: don't use YY_ASSERT at all if parse.assert is disabled c++: style: follow the Bison m4 quoting pattern yacc.c: provide the Bison version as an integral macro regen style: make conversion of version string to int public %require: accept version numbers with three parts ("3.7.4") yacc.c: fix #definition of YYEMPTY gnulib: update doc: fix incorrect section title doc: minor grammar fixes in counterexamples section
| * lalr1.cc: YY_ASSERT should use api.prefixAkim Demaille2020-11-131-9/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Working on the previous commit I realized that YY_ASSERT was used in the generated headers, so must follow api.prefix to avoid clashes when multiple C++ parser with variants are used. Actually many more macros should obey api.prefix (YY_CPLUSPLUS, YY_COPY, etc.). There was no complaint so far, so it's not urgent enough for 3.7.4, but it should be addressed in 3.8. * data/skeletons/variant.hh (b4_assert): New. Use it. * tests/local.at (AT_YYLEX_RETURN): Fix. * tests/headers.at: Make sure variant-based C++ parsers are checked too. This test did find that YY_ASSERT escaped renaming (before the fix in this commit).
* | options: rename --defines as --headerAkim Demaille2020-09-191-2/+1
|/ | | | | | | | | | | | | | | | | | The name "defines" is incorrect, the generated file contains far more than just #defines. * src/getargs.h, src/getargs.c (-H, --header): New option. With optional argument, just like --defines, --xml, etc. (defines_flag): Rename as... (header_flag): this. Adjust dependencies. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.c, * data/skeletons/glr.cc, data/skeletons/glr2.cc, data/skeletons/lalr1.cc, * data/skeletons/yacc.c: Adjust. * examples, doc/bison.texi: Adjust. * tests/headers.at, tests/local.at, tests/output.at: Convert most tests from using --defines to using --header.
* error: rename the error token from YYERRCODE to YYerrorAkim Demaille2020-04-281-1/+1
| | | | | | | | | | | See https://lists.gnu.org/r/bison-patches/2020-04/msg00162.html. * data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/glr.cc, * data/skeletons/lalr1.java, doc/bison.texi, * examples/c/bistromathic/parse.y, src/scan-gram.l, src/symtab.c (YYERRCODE): Rename as... (YYerror): this. Adjust dependencies.
* all: prefer YYERRCODE to YYERRORAkim Demaille2020-04-261-1/+1
| | | | | | | | | | | | | We will not keep YYERRCODE anyway, it causes backward compatibility issues. So as a first step, let all the skeletons use that name, until we have a better one. * data/skeletons/bison.m4, data/skeletons/glr.c, * data/skeletons/glr.cc, data/skeletons/lalr1.cc, * data/skeletons/lalr1.d, data/skeletons/lalr1.java, * data/skeletons/yacc.c, doc/bison.texi, tests/headers.at, * tests/input.at: here.
* doc: spell checkAkim Demaille2020-04-131-1/+1
| | | | | * doc/bison.texi, NEWS, README-hacking.md: here. And elsewhere.
* c++: fix generated headersAkim Demaille2020-04-121-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A forthcoming commit (tokens: properly define the "error" token kind) revealed a problem in the C++ generated headers: they are not self-contained. With this file: %language "c++" %define api.value.type variant %code { static int yylex (yy::parser::semantic_type *lvalp); } %token <int> X %% exp: X { printf ("x\n"); } ; %% void yy::parser::error (const std::string& m) { std::cerr << m << '\n'; } static int yylex (yy::parser::semantic_type *lvalp) { static int const input[] = {yy::parser::token::X, 0}; static int toknum = 0; return input[toknum++]; } int main (int argc, char const* argv[]) { yy::parser p; return p.parse (); } the generated header fails to compile cleanly (foo.cc just #includes the generated header): $ clang++-mp-9.0 -c -Wundefined-func-template foo.cc In file included from foo.cc:1: bar.tab.hh:550:12: warning: instantiation of function 'yy::parser::basic_symbol<yy::parser::by_type>::basic_symbol' required here, but no definition is available [-Wundefined-func-template] struct symbol_type : basic_symbol<by_type> ^ bar.tab.hh:436:7: note: forward declaration of template entity is here basic_symbol (basic_symbol&& that); ^ bar.tab.hh:550:12: note: add an explicit instantiation declaration to suppress this warning if 'yy::parser::basic_symbol<yy::parser::by_type>::basic_symbol' is explicitly instantiated in another translation unit struct symbol_type : basic_symbol<by_type> ^ 1 warning generated. * data/skeletons/c++.m4 (b4_public_types_define): Move the implementation of the basic_symbol move-ctor to... (b4_public_types_define): here, its declaration. * tests/headers.at (Sane headers): Use a declared token so that the corresponding token constructor is declared. Which triggers the aforementioned issue.
* c++: improvements on symbol kindsAkim Demaille2020-04-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of /// (Internal) symbol kind. enum symbol_kind_type { YYNTOKENS = 5, ///< Number of tokens. YYSYMBOL_YYEMPTY = -2, YYSYMBOL_YYEOF = 0, // END_OF_FILE YYSYMBOL_YYERROR = 1, // error YYSYMBOL_YYUNDEF = 2, // $undefined YYSYMBOL_TEXT = 3, // TEXT YYSYMBOL_NUMBER = 4, // NUMBER YYSYMBOL_YYACCEPT = 5, // $accept YYSYMBOL_result = 6, // result YYSYMBOL_list = 7, // list YYSYMBOL_item = 8 // item }; generate /// Symbol kinds. struct symbol_kind { enum symbol_kind_type { YYNTOKENS = 5, ///< Number of tokens. S_YYEMPTY = -2, S_YYEOF = 0, // END_OF_FILE S_YYERROR = 1, // error S_YYUNDEF = 2, // $undefined S_TEXT = 3, // TEXT S_NUMBER = 4, // NUMBER S_YYACCEPT = 5, // $accept S_result = 6, // result S_list = 7, // list S_item = 8 // item }; }; * data/skeletons/c++.m4 (api.symbol.prefix): Define to S_. Adjust all the uses. (b4_public_types_declare): Nest the enum inside 'struct symbol_kind'. * data/skeletons/glr.cc, data/skeletons/lalr1.cc, * tests/headers.at, tests/local.at: Adjust.
* c++: also use symbol_type_typeAkim Demaille2020-04-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Because of the insane current implementation of glr.cc, things are a bit nasty. We will rename symbol_number_type as symbol_type_type later, to keep this commit small. * data/skeletons/c++.m4 (b4_declare_symbol_enum): New. Also define YYNTOKENS to avoid type clashes when yyntokens_ was actually defined in another enum. Use it. (symbol_number_type): Be an alias of symbol_type_type. Use YYSYMBOL_YYEMPTY and the like. Use symbol_number_type where appropriate. (empty_symbol): Remove. (yytranslate_): Use symbol_number_type, not token_number_type. * data/skeletons/lalr1.cc: Use symbol_number_type where appropriate. Adjust to the replacement of empty_symbol by YYSYMBOL_YYEMPTY. (yy_error_token_, yy_undef_token_, yyeof_, yyntokens_): Remove. Adjust dependencies. * data/skeletons/glr.cc: Use symbol_number_type where appropriate. Forward definitions of YYSYMBOL_YYEMPTY, etc. to glr.c. * tests/headers.at: Accept YYNTOKENS and other YYSYMBOL_*. * tests/local.at (AT_YYERROR_DEFINE(c++)): Use symbol_number_type.
* package: bump copyrights to 2020Akim Demaille2020-01-051-1/+1
| | | | Run 'make update-copyright'.
* warnings: enable -Wuseless-cast, and eliminate warningsAkim Demaille2019-12-061-1/+1
| | | | | | | | | | | | | | Prompted by Frank Heckenbach. https://lists.gnu.org/archive/html/bug-bison/2019-11/msg00016.html. * configure.ac (warn_cxx): Add -Wuseless-cast. * data/skeletons/c.m4 (b4_attribute_define): Define YY_IGNORE_USELESS_CAST_BEGIN and YY_IGNORE_USELESS_CAST_END. * data/skeletons/glr.c (YY_FPRINTF): New, replaces YYFPRINTF, wrapped with YY_IGNORE_USELESS_CAST_BEGIN and YY_IGNORE_USELESS_CAST_END. (YY_DPRINTF): Likewise. * tests/actions.at: Remove useless cast. * tests/headers.at: Adjust.
* c++: fix old cast warningsAkim Demaille2019-11-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | We still have a few old C casts in lalr1.cc, let's get rid of them. Reported by Frank Heckenbach. Actually, let's monitor all our casts using easy to grep macros. Let's use these macros to use the C++ standard casts when we are in C++. * data/skeletons/c.m4 (b4_cast_define): New. * data/skeletons/glr.c, data/skeletons/glr.cc, * data/skeletons/lalr1.cc, data/skeletons/stack.hh, * data/skeletons/yacc.c: Use it and/or its casts. * tests/actions.at, tests/cxx-type.at, * tests/glr-regression.at, tests/headers.at, tests/torture.at, * tests/types.at: Use YY_CAST instead of C casts. * configure.ac (warn_cxx): Add -Wold-style-cast. * doc/bison.texi: Disable it.
* tests: beware of GCC9 warnings in push modeAkim Demaille2019-10-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This is really weird: GCC points to the LHS of the assignment... 260. headers.at:184: testing Sane headers: api.pure api.push-pull=both ... tests/headers.at:184: COLUMNS=1000; export COLUMNS; bison --color=no -fno-caret -d -o input.c input.y tests/headers.at:184: $CC $CFLAGS $CPPFLAGS -c -o input.o input.c stderr: input.c: In function 'yyparse': input.c:1276:16: error: 'yylval' may be used uninitialized in this function [-Werror=maybe-uninitialized] 1276 | yylval = *yypushed_val; | ~~~~~~~^~~~~~~~~~~~~~~ input.c: In function 'yypull_parse': input.c:1276:16: error: 'yylval' may be used uninitialized in this function [-Werror=maybe-uninitialized] 1276 | yylval = *yypushed_val; | ~~~~~~~^~~~~~~~~~~~~~~ cc1: all warnings being treated as errors stdout: tests/headers.at:184: exit code was 1, expected 0 See also d87c8ac79ab844d6a7a4f5103dcf7a842d18b611 and 9645a2b20ee7cbfa8bb4ac2237f87d598afe349c. * tests/headers.at (Several parsers, Several parsers): Disable these warnings when in push parser.
* c: port YY_ATTRIBUTE_UNUSED to Sun C 5.12Paul Eggert2019-10-171-1/+1
| | | | | | | | | | | | Sun C 5.12 defines __SUNPRO_C to 0x5120 but diagnoses ‘__attribute__ ((__unused__))’. Change the ifdefs to use the same method as Gnulib in this area. * data/skeletons/c.m4 (YY_ATTRIBUTE): Remove, since not all attributes were added in the same compiler version. (YY_ATTRIBUTE_PURE, YY_ATTRIBUTE_UNUSED): Use specific GCC version for each attribute. Pay no attention to __SUNPRO_C. * tests/headers.at (Several parsers): Tighten tests accordingly.
* tests: refactor the handling of PerlAkim Demaille2019-10-131-2/+2
| | | | | | | | | | | | | | Let's make a difference between places where Perl is required for the test (AT_PERL_REQUIRE), and the places where it's used to run the test, but it's not not to run the test (AT_PERL_CHECK). * tests/local.at (AT_REQUIRE): New. (AT_PERL_CHECK, AT_PERL_REQUIRE): New. Use them where appropriate. * tests/local.mk ($(TESTSUITE)): Beware not to start the line with '-pi' if Perl is empty, as Make understands this as "it's ok to fail". Which it is not.
* tests: be really robust to Perl missingAkim Demaille2019-10-111-2/+2
| | | | | | | | | | | My previous tests (with ./configure PERL=false) have been fooled by configure, that managed to find perl anyway. This time, I ran this on a Fedora in Docker, without Perl. * tests/calc.at, tests/diagnostics.at, tests/headers.at, * tests/input.at, tests/local.at, tests/named-refs.at, * tests/output.at, tests/regression.at, tests/skeletons.at, * tests/synclines.at, tests/torture.at: Don't require Perl.
* tests: add missing includesAkim Demaille2019-10-101-0/+2
| | | | | * tests/actions.at, tests/c++.at, tests/headers.at, * tests/regression.at: here.
* api.location.type: support it in CAkim Demaille2019-04-251-1/+0
| | | | | | | | | | | | Reported by Balázs Scheidler. * data/skeletons/c.m4 (b4_location_type_define): Use api.location.type if defined. * doc/bison.texi: Document it. * tests/local.at (AT_C_IF, AT_LANG_CASE): New. Support Span in C. * tests/calc.at (Span): Convert it to be usable in C and C++. Check api.location.type with yacc.c and glr.c.
* tests: simplify AT_PARSER_CHECK usageAkim Demaille2019-02-211-2/+2
| | | | | | | | | Currently the caller must specify the ./ prefix to its command. Let's avoid that: it will be nicer to read, make it easier to have a version that works for Java and C/C++. * tests/local.at (AT_PARSER_CHECK): Prefix the command with ./. Adjust callers.
* c++: address -Wweak-vtables warningsAkim Demaille2019-01-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Reported by Derek Clegg http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00021.html aux/parser-internal.h:429:12: error: 'syntax_error' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Werror,-Wweak-vtables] struct syntax_error : std::runtime_error To avoid this warning, we need syntax_error to have a virtual function defined in a compilation unit. Let it be the destructor. To comply with C++98, this dtor should be 'throw()'. Merely making YY_NOEXCEPT be 'throw()' in C++98 triggers errors (http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00022.html), so let's introduce YY_NOTHROW and flag only ~syntax_error with it. Also, since we now have an explicit dtor, we need to provide an copy ctor. * configure.ac (warn_cxx): Add -Wweak-vtables. * data/skeletons/c++.m4 (YY_NOTHROW): New. (syntax_error): Declare the dtor, and define the copy ctor. * data/skeletons/glr.cc, data/skeletons/lalr1.cc (~syntax_error): Define.
* fixits: suggest running --update if there are fixitsAkim Demaille2019-01-161-0/+1
| | | | | | | | | | | * src/fixits.h, src/fixits.c (fixits_empty): New. * src/complain.c (deprecated_directive): Register the Wdeprecated fixits only if -Wdeprecated was enabled, so that we don't apply updates if the user didn't ask for them. * src/main.c (main): If there were fixits, issue a warning suggesting running with --update. Free uniqstrs after the fixits, since the latter use the former. * tests/headers.at, tests/input.at: Update expectations.
* c++: avoid -Wundefined-func-template warnings from clangAkim Demaille2019-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reported by Derek Clegg. http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00006.html Clang does not like this: template <typename D> struct basic_symbol : D { basic_symbol(); }; struct by_type {}; struct symbol_type : basic_symbol<by_type> { symbol_type(){} }; It gives: $ clang++-mp-7.0 -Wundefined-func-template foo.cc -c foo.cc:11:3: warning: instantiation of function 'basic_symbol<by_type>::basic_symbol' required here, but no definition is available [-Wundefined-func-template] symbol_type(){} ^ foo.cc:4:3: note: forward declaration of template entity is here basic_symbol(); ^ foo.cc:11:3: note: add an explicit instantiation declaration to suppress this warning if 'basic_symbol<by_type>::basic_symbol' is explicitly instantiated in another translation unit symbol_type(){} ^ 1 warning generated. The same applies for the basic_symbol's destructor and `clear()`. * configure.ac (warn_cxx): Add -Wundefined-func-template. This triggered one failure in the test suite: * tests/headers.at (Sane headers): here, where we check that we can compile the generated headers in other compilation units than the parser's. Add a variant type to make sure that basic_symbol and symbol_type are properly generated in this case. * data/skeletons/c++.m4 (basic_symbol): Inline the definitions of the destructor and of `clear` in the class definition.
* diagnostics: improve them for %name-prefixAkim Demaille2019-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the diagnostics for %name-prefix are not precise enough. In particular, they does not show that braces must be used instead of quotes. Before: foo.y:3.1-14: warning: deprecated directive, use '%define api.prefix' [-Wdeprecated] %name-prefix = "foo" ^^^^^^^^^^^^^^ After: foo.y:3.1-20: warning: deprecated directive, use '%define api.prefix {foo}' [-Wdeprecated] %name-prefix = "foo" ^^^^^^^^^^^^^^^^^^^^ To do this we need the value passed to %name-prefix, so move the warning from the scanner to the parser. Accuracy will be very important for the forthcoming changes. * src/parse-gram.y (do_name_prefix): New. (PERCENT_NAME_PREFIX): Have a semantic value: the raw source, with possibly underscores, equal sign, and spaces. This is used to provide a more accurate message. It does not take comments into account, but... * src/scan-gram.l (%name-prefix): Delegate the warnings to the parser. * tests/headers.at, tests/input.at: Adjust expectations.
* package: bump copyrights to 2019Akim Demaille2019-01-051-1/+1
|
* clearly deprecate %name-prefixAkim Demaille2019-01-031-1/+3
| | | | | | | | | | | * src/scan-gram.l (%name-prefix): Issue a deprecation warning. * tests/calc.at, tests/headers.at, tests/input.at, tests/java.at, * tests/javapush.at, tests/local.at: Adjust expectations. Or disable -Wdeprecated. * doc/bison.texi: Document that %name-prefix is replaced by %define api.prefix.
* c++: check several parsers in the same programAkim Demaille2018-12-271-4/+6
| | | | | | | | * tests/local.at (AT_LOCATION_TYPE_IF): Turn into... (AT_LOCATION_TYPE_SPAN_IF): this. Adjust dependencies. * tests/headers.at (Several parsers): Add another C++ parser, which uses the first C++ parser's locations.
* C++: use noexcept and constexprAkim Demaille2018-12-011-0/+2
| | | | | | | There are probably more opportunities for them. So far, I observed no performance improvements. * data/c++.m4, data/lalr1.cc, data/stack.hh: here.
* c++: factor the handling of __cplusplus into YY_CPLUSPLUSAkim Demaille2018-11-131-0/+1
| | | | | | * data/c++.m4 (b4_cxx_portability): Define it. Use it. * data/lalr1.cc, data/variant.hh: Use it.
* tests: migrate from %error-verbose to %define parse.error verboseAkim Demaille2018-11-121-2/+2
| | | | | | | | | * tests/actions.at, tests/c++.at, tests/conflicts.at, * tests/cxx-type.at, tests/existing.at, tests/glr-regression.at, * tests/headers.at, tests/input.at, tests/java.at, tests/javapush.at, * tests/local.at, tests/regression.at, tests/skeletons.at, * tests/torture.at: Here.
* c++: improve the generated documentationAkim Demaille2018-11-041-2/+2
| | | | | | | * data/lalr1.cc, data/location.cc: Improve documenting comments. * tests/c++.at (Doxygen Documentation): Fix AT_BISON_OPTION_PUSHDEFS, so that the generated yyerror is correct. * tests/c++.at, tests/headers.at: Prefer %empty.
* style: tests: factor file extension computationsAkim Demaille2018-10-061-4/+4
| | | | | | * tests/local.at (AT_LANG_HDR): New. * tests/calc.at, tests/headers.at, tests/synclines.at: Use it, and AT_LANG_EXT.
* lalr1.cc: support move semanticsAkim Demaille2018-09-131-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modern C++ (i.e., C++11 and later) introduced "move only" types: types such as std::unique_ptr<T> that can never be duplicated. They must never be copied (by assignments and constructors), they must be "moved". The implementation of lalr1.cc used to copy symbols (including their semantic values). This commit ensures that values are only moved in modern C++, yet remain compatible with C++98/C++03. Suggested by Frank Heckenbach, who provided a full implementation on top of C++17's std::variant. See http://lists.gnu.org/archive/html/bug-bison/2018-03/msg00002.html, and https://lists.gnu.org/archive/html/bison-patches/2018-04/msg00002.html. Symbols (terminal/non terminal) are handled by several functions that used to take const-refs, which resulted eventually in a copy pushed on the stack. With modern C++ (C++11 and later) the callers must use std::move, and the callees must take their arguments as rvalue refs (foo&&). In order to avoid duplicating these functions to support both legacy C++ and modern C++, let's introduce macros (YY_MOVE, YY_RVREF, etc.) that rely on copy-semantics for C++98/03, and move-semantics for modern C++. That's easy for inner types, when the parser's functions pass arguments to each other. Functions facing the user (make_NUMBER, make_STRING, etc.) should support both rvalue-refs (for instance to support move-only types: make_INT (std::make_unique<int> (1))), and lvalue-refs (so that we can pass a variable: make_INT (my_int)). To avoid the multiplication of the signatures (there is also the location), let's take the argument by value. See: https://lists.gnu.org/archive/html/bison-patches/2018-09/msg00024.html. * data/c++.m4 (b4_cxx_portability): New. (basic_symbol): In C++11, replace copy-ctors with move-ctors. In C++11, replace copies with moves. * data/lalr1.cc (stack_symbol_type, yypush_): Likewise. Use YY_MOVE to avoid useless copies. * data/variant.hh (variant): Support move-semantics. (make_SYMBOL): In C++11, in order to support both read-only lvalues, and rvalues, take the argument as a copy. * data/stack.hh (yypush_): Use rvalue-refs in C++11. * tests/c++.at: Use move semantics. * tests/headers.at: Adjust to the new macros (YY_MOVE, etc.). * configure.ac (CXX98_CXXFLAGS, CXX11_CXXFLAGS, CXX14_CXXFLAGS) (CXX17_CXXFLAGS, ENABLE_CXX11): New. * tests/atlocal.in: Receive them. * examples/variant.yy: Don't define things in std. * examples/variant-11.test, examples/variant-11.yy: New. Check the support of move-only types. * examples/README, examples/local.mk: Adjust.
* tests: disable GCC7 warnings for some testsAkim Demaille2018-09-021-4/+12
| | | | | | | | | | | | | | | | | | | | 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 9645a2b20ee7cbfa8bb4ac2237f87d598afe349c. * 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.
* C++: make sure the generated header is self containerAkim Demaille2018-08-261-3/+3
| | | | | | | See the previous commit. * data/lalr1.cc: Be sure to define YY_NULLPTR. * tests/headers.at: Check the case that was failing.
* tests: check that headers are saneAkim Demaille2018-08-261-21/+89
| | | | | | | | 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.
* Update copyright yearsAkim Demaille2018-05-121-1/+1
| | | | Run `make update-copyright`.
* style: don't use std::endlAkim Demaille2018-05-081-1/+1
| | | | | | | | * 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.
* package: bump to 2015Akim Demaille2015-01-041-1/+1
| | | | | | Which also requires: * gnulib: Update.
* package: bump to 2014Akim Demaille2014-02-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * AUTHORS, ChangeLog-2012, Makefile.am, NEWS, PACKAGING, README, * README-alpha, README-hacking, THANKS, TODO, bootstrap.conf, * build-aux/darwin11.4.0.valgrind, build-aux/local.mk, * build-aux/update-b4-copyright, * build-aux/update-package-copyright-year, cfg.mk, configure.ac, * data/README, data/bison.m4, data/c++-skel.m4, data/c++.m4, * data/c-like.m4, data/c-skel.m4, data/c.m4, data/glr.c, data/glr.cc, * data/java-skel.m4, data/java.m4, data/lalr1.cc, data/lalr1.java, * data/local.mk, data/location.cc, data/stack.hh, data/variant.hh, * data/xslt/bison.xsl, data/xslt/xml2dot.xsl, data/xslt/xml2text.xsl, * data/xslt/xml2xhtml.xsl, data/yacc.c, djgpp/Makefile.maint, * djgpp/README.in, djgpp/config.bat, djgpp/config.sed, * djgpp/config.site, djgpp/config_h.sed, djgpp/djunpack.bat, * djgpp/local.mk, djgpp/subpipe.c, djgpp/subpipe.h, * djgpp/testsuite.sed, doc/bison.texi, doc/local.mk, doc/refcard.tex, * etc/README, etc/bench.pl.in, etc/local.mk, * examples/calc++/calc++.test, examples/calc++/local.mk, * examples/extexi, examples/local.mk, examples/mfcalc/local.mk, * examples/mfcalc/mfcalc.test, examples/rpcalc/local.mk, * examples/rpcalc/rpcalc.test, examples/test, examples/variant.yy, * lib/abitset.c, lib/abitset.h, lib/bbitset.h, lib/bitset.c, * lib/bitset.h, lib/bitset_stats.c, lib/bitset_stats.h, * lib/bitsetv-print.c, lib/bitsetv-print.h, lib/bitsetv.c, * lib/bitsetv.h, lib/ebitset.c, lib/ebitset.h, lib/get-errno.c, * lib/get-errno.h, lib/lbitset.c, lib/lbitset.h, lib/libiberty.h, * lib/local.mk, lib/main.c, lib/timevar.c, lib/timevar.def, * lib/timevar.h, lib/vbitset.c, lib/vbitset.h, lib/yyerror.c, * m4/bison-i18n.m4, m4/c-working.m4, m4/cxx.m4, m4/flex.m4, * m4/timevar.m4, src/AnnotationList.c, src/AnnotationList.h, * src/InadequacyList.c, src/InadequacyList.h, src/LR0.c, src/LR0.h, * src/Sbitset.c, src/Sbitset.h, src/assoc.c, src/assoc.h, * src/closure.c, src/closure.h, src/complain.c, src/complain.h, * src/conflicts.c, src/conflicts.h, src/derives.c, src/derives.h, * src/files.c, src/files.h, src/flex-scanner.h, src/getargs.c, * src/getargs.h, src/gram.c, src/gram.h, src/graphviz.c, * src/graphviz.h, src/ielr.c, src/ielr.h, src/lalr.c, src/lalr.h, * src/local.mk, src/location.c, src/location.h, src/main.c, * src/muscle-tab.c, src/muscle-tab.h, src/named-ref.c, * src/named-ref.h, src/nullable.c, src/nullable.h, src/output.c, * src/output.h, src/parse-gram.c, src/parse-gram.y, src/print-xml.c, * src/print-xml.h, src/print.c, src/print.h, src/print_graph.c, * src/print_graph.h, src/reader.c, src/reader.h, src/reduce.c, * src/reduce.h, src/relation.c, src/relation.h, src/scan-code.h, * src/scan-code.l, src/scan-gram.h, src/scan-gram.l, src/scan-skel.h, * src/scan-skel.l, src/state.c, src/state.h, src/symlist.c, * src/symlist.h, src/symtab.c, src/symtab.h, src/system.h, * src/tables.c, src/tables.h, src/uniqstr.c, src/uniqstr.h, * tests/actions.at, tests/atlocal.in, tests/bison.in, tests/c++.at, * tests/calc.at, tests/conflicts.at, tests/cxx-type.at, * tests/existing.at, tests/glr-regression.at, tests/headers.at, * tests/input.at, tests/java.at, tests/javapush.at, tests/local.at, * tests/local.mk, tests/named-refs.at, tests/output.at, tests/push.at, * tests/reduce.at, tests/regression.at, tests/sets.at, * tests/skeletons.at, tests/synclines.at, tests/testsuite.at, * tests/torture.at, tests/types.at: here.
* parsers: rename YY_NULL as YY_NULLPTR to avoid conflicts with FlexAkim Demaille2013-11-081-1/+1
| | | | | | | | | | | | Flex also defines YY_NULL (to 0). Avoid gratuitous conflicts. * data/c.m4 (b4_null_define): Rename YY_NULL as YY_NULLPTR. * data/glr.c, data/lalr1.cc, data/location.cc, data/variant.hh, * data/yacc.c, src/parse-gram.c, tests/actions.at, tests/c++.at, * tests/cxx-type.at, tests/glr-regression.at, tests/headers.at, * tests/push.at, tests/regression.at: Adjust.
* c++: use __attribute__((__pure__)) to avoid warningsAkim Demaille2013-11-051-1/+5
| | | | | | | | | | 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".
* muscle: check more cases of %define variables with code valuesAkim Demaille2013-04-181-2/+2
| | | | | | | | | | | | | | * data/bison.m4 (b4_percent_define_check_kind): Fix overquotation. (api.location.type, api.position.type): Check they have code values here. * data/c++.m4 (api.location.type): No longer checked here. (parser_class_name): Check it here. * data/java.m4 (api.value.type, init_throws, lex_throws, parser_class_name) (throws, annotations, extends, implements): Check they have code values. * doc/bison.texi: Fix every incorrect occurrence of %define. Document the additional syntax for %define: code values. Document the additional syntax for -D/-F: string and code values. * tests/calc.at, tests/headers.at, tests/input.at, tests/java.at, * tests/local.at: Fix dependencies.