Commit Graph

41 Commits

Author SHA1 Message Date
Akim Demaille
2b52bd1644 glr2.cc: style fixes
* data/skeletons/glr2.cc: Formatting changes.
2020-12-14 06:33:12 +01:00
Akim Demaille
9ee51ece65 glr2.cc: add sanity check in glr_state
The use of YY_IGNORE_NULL_DEREFERENCE_BEGIN/END in `check_` is to
please GCC 10:

    glr-regr8.cc: In member function 'YYRESULTTAG glr_stack::yyresolveValue(glr_state&)':
    glr-regr8.cc:1433:21: error: potential null pointer dereference [-Werror=null-dereference]
     1433 |     YYASSERT (this->magic_ == MAGIC);
          |               ~~~~~~^~~~~~
    glr-regr8.cc:905:40: note: in definition of macro 'YYASSERT'
      905 | # define YYASSERT(Condition) ((void) ((Condition) || (abort (), 0)))
          |                                        ^~~~~~~~~

* data/skeletons/glr2.cc (glr_state::check_): New.
Use it in the member functions.
2020-12-13 06:59:04 +01:00
Akim Demaille
2313f891bd glr2.cc: add sanity checks in glr_stack_item
We obviously have broken pointer arithmetics that hands us
glr_stack_items that are not glr_stack_items.  Have a simple check for
this, to have earlier failures.

* data/skeletons/glr2.cc (glr_stack_item::check_): New.
Use it.
(glr_stack_item::contents): Avoid the useless struct.
Fix minor stylistic issues.
2020-12-13 06:31:41 +01:00
Akim Demaille
4beefee4bf glr2.cc: use the same format for traces as glr.c
* data/skeletons/glr2.cc: here.
This allows to share the same expected output.
2020-12-06 14:02:38 +01:00
Akim Demaille
3301849f0f glr2.cc: add support for parse.assert
* data/skeletons/glr2.cc: Fake support of parse.assert, so that the
tests can use it without failing.
2020-12-06 14:02:38 +01:00
Akim Demaille
349ea900f5 glr2.cc: fix yyresolveValue
When "tests: glr2.cc: run the glr-regression tests" tests are run,
before this commit the following tests used to loop endlessly:

    709: Badly Collapsed GLR States: glr2.cc             FAILED (glr-regression.at:123)
    715: Improper merging of GLR delayed action sets: glr2.cc FAILED (glr-regression.at:397)
    718: Duplicate representation of merged trees: glr2.cc FAILED (glr-regression.at:495)
    751: Leaked semantic values when reporting ambiguity: glr2.cc FAILED (glr-regression.at:1632)

After this commit, no test loops and 709, 715, and 751 pass.  Only 718
still fails.

* data/skeletons/glr2.cc (yyresolveValue): Add missing incrementation
of the iteration variable.
2020-12-06 14:02:38 +01:00
Valentin Tolmer
1b85ac4586 glr2.cc: misc cleanups
* data/skeletons/glr2.cc: Use 'const' on variables and applicable
member functions.
Improve comments.
Use references where applicable.
Enforce names_like_this, notLikeThis.
Reduce scopes.
2020-12-06 14:02:38 +01:00
Valentin Tolmer
2ec6df3b07 glr2.cc: fix memory corruption bug
* data/skeletons/glr2.cc (yyremoveDeletes): Remove double-increment in
the loop.
(glr_state::copyFrom): Handle gracefully when other is resolved.
2020-12-06 14:02:38 +01:00
Akim Demaille
e72eda7aee glr2.cc: turn some pointers into references
* data/skeletons/glr2.cc: Prefer references to pointers.
Add a few more const.
2020-12-06 14:02:38 +01:00
Valentin Tolmer
4f24f5f304 glr2.cc: use 'const' for some constant local variables
* data/skeletons/glr2.cc: here.
2020-12-06 13:54:45 +01:00
Akim Demaille
12b5924939 glr2.cc: fix when the stack is not expandable
* data/skeletons/glr2.cc (yyexpandGLRStackIfNeeded): Fix the
implementation when !YYSTACKEXPANDABLE.
2020-12-06 13:54:45 +01:00
Akim Demaille
3b80811cfa glr2.cc: remove scaffolding for glr.c
* data/skeletons/glr2.cc (b4_glr_cc_setup, b4_glr_cc_cleanup): Remove.
2020-11-07 17:28:25 +01:00
Akim Demaille
5a31cda4c3 style: avoid explicit symbol numbers
This should have been part of commit "symbols: stop dealing with YYEMPTY
as b4_symbol(-2, ...)" (cd40ec9526).
Give names to all the special symbols: "eof", "error" and "undef".

* data/skeletons/bison.m4 (b4_symbol): Let `b4_symbol(eof, ...)` mean
`b4_symbol(0, ...)`, `b4_symbol(error, ...)` mean `b4_symbol(1, ...)`,
and , `b4_symbol(undef, ...)` mean `b4_symbol(2, ...)`..

* data/skeletons/c.m4, data/skeletons/glr.c, data/skeletons/glr.cc,
* data/skeletons/glr2.cc, data/skeletons/lalr1.cc,
* data/skeletons/lalr1.d, data/skeletons/lalr1.java,
* data/skeletons/yacc.c:
Prefer symbols to numbers.
2020-11-07 16:58:47 +01:00
Akim Demaille
cd40ec9526 symbols: stop dealing with YYEMPTY as b4_symbol(-2, ...)
* data/skeletons/bison.m4 (b4_symbol): Redirect `b4_symbol(empty,
...)` to `b4_symbol(-2, ...)`.
Change all uses of the latter to the former.
2020-09-29 06:49:31 +02:00
Akim Demaille
f9b360663b glr2.cc: add an example
Currently this example crashes on input such as "T (x) + y;".
The same example with glr.c works properly.

* examples/c++/glr/Makefile, examples/c++/glr/README.md,
* examples/c++/glr/c++-types.test, examples/c++/glr/c++-types.yy,
* examples/c++/glr/local.mk, examples/c++/local.mk: New.
Based on examples/c/glr/c++-types.y.
2020-09-26 18:33:48 +02:00
Akim Demaille
8dc60543c8 glr2.cc: also run all the calculator tests
This revealed issues with yy_symbol_print and yy_reduce_print.
These changes, in turn, reactivated GCC10 warnings:

    559. calc.at:1258: testing Calculator glr2.cc %locations %header parse.error=verbose %debug api.prefix={calc} %verbose %parse-param {semantic_value *result}{int *count}{int *nerrs}  ...
    tests/calc.at:1258: COLUMNS=1000; export COLUMNS; NO_TERM_HYPERLINKS=1; export NO_TERM_HYPERLINKS;  bison --color=no -fno-caret -Wno-deprecated -o calc.cc calc.y
    tests/calc.at:1258: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o calc calc.cc calc-lex.cc calc-main.cc $LIBS
    stderr:
    calc.cc: In function 'void glr_stack::yyresolveLocations(glr_state*, int)':
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc:1177:10: error: potential null pointer dereference [-Werror=null-dereference]
     1177 |   return yypred ? &(asItem (this) - yypred)->getState () : YY_NULLPTR;
          |          ^~~~~~
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    calc.cc: In member function 'YYRESULTTAG glr_stack::yyresolveValue(glr_state*)':
    calc.cc:2623:46: error: potential null pointer dereference [-Werror=null-dereference]
     2623 |                 yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

* tests/calc.at (AT_CHECK_CALC_GLR_CC): Also check glr2.cc.
* data/skeletons/glr2.cc: Don't pass the user arguments to
yy_symbol_print and yy_reduce_print, since they have it in the parser
object.
(b4_user_formals_no_comma, b4_pure_args, b4_lpure_args)
(b4_locuser_formals, b4_locuser_args): Remove, useless.
(YY_IGNORE_NULL_DEREFERENCE_BEGIN): Enable for GCC >= 10 too.
2020-09-21 06:43:10 +02:00
Akim Demaille
75c3746ce2 options: rename --defines as --header
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.
2020-09-19 08:31:49 +02:00
Valentin Tolmer
12a5cc07e0 glr2.cc: replace refs to parser::symbol_kind_type with yysymbol_kind_t
* data/skeletons/glr2.cc: here.
2020-09-17 19:37:05 +02:00
Valentin Tolmer
27b5d92563 glr2.cc: fix container out-of-bounds access
Clang 10 with ASAN enabled reported errors in glr2.cc.

* data/skeletons/glr2.cc: here.
2020-09-17 19:35:47 +02:00
Akim Demaille
34476c449a glr2.cc: disable GCC 4.6 warning
231. conflicts.at:1096: testing Syntax error in consistent error state: glr2.cc ...
    tests/conflicts.at:1096: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o input input.cc $LIBS
    input.cc: In member function 'YYRESULTTAG glr_stack::yyresolveValue(glr_state*)':
    input.cc:2674:36: error: 'yysval' may be used uninitialized in this function [-Werror=uninitialized]

Do not initialize the variable: this way ASAN can really make sure we
do set it to a proper value.
If we initialize it, ASAN would report nothing.

* data/skeletons/c.m4 (YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN): Disable
GCC 4.6's -Wuninitialized.
* data/skeletons/glr2.cc: Disable the warning locally.
2020-09-15 07:27:00 +02:00
Akim Demaille
795a59aba4 glr2.cc: fix warning with GCC 4.7 and 4.8
231. conflicts.at:1096: testing Syntax error in consistent error state: glr2.cc ...
    tests/conflicts.at:1096: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o input input.cc $LIBS
    input.cc: In function 'int yyparse(yy::parser&)':
    input.cc:3147:41: error: 'yyarg' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         return yytnamerr_ (yytname_[yysymbol]);
                                             ^
    input.cc:2058:34: note: 'yyarg' was declared here
         yy::parser::symbol_kind_type yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
                                      ^

* data/skeletons/glr2.cc (yyreportSyntaxError): Initialize yyarg.
2020-09-14 19:53:01 +02:00
Akim Demaille
243fa94ce2 glr2.cc: simplify symbol kinds
We emit code like

    if (yytoken != yy::parser::symbol_kind::symbol_kind::S_YYEMPTY)

* data/skeletons/glr2.cc: Use b4_symbol correctly.
2020-09-14 19:30:48 +02:00
Akim Demaille
11995fec50 glr2.cc: fix warning about local variable vs. member
Fix a warning triggered in GCC (at least from 4.6 to 4.9):

    input.cc: In constructor 'glr_stack_item::glr_stack_item(bool)':
    input.cc:1371:5: error: declaration of 'is_state' shadows a member of 'this' [-Werror=shadow]
         : is_state_(is_state)
         ^

* data/skeletons/glr2.cc (glr_stack_item): Alpha-convert.
2020-09-14 06:34:07 +02:00
Akim Demaille
5c37f5994d glr2.cc: avoid type-punning issues
On the CI, tests fail with GCC 4.6 to GCC 6 as follows:

    tests/synclines.at:440: COLUMNS=1000; export COLUMNS; NO_TERM_HYPERLINKS=1; export NO_TERM_HYPERLINKS;  bison --color=no -fno-caret  -o \"\\\"\".cc \"\\\"\".y
    tests/synclines.at:440: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o \"\\\"\" \"\\\"\".cc $LIBS
    stderr:
    "\"".cc: In member function 'glr_state& glr_stack_item::getState()':
    "\"".cc:1404:47: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
         return *reinterpret_cast<glr_state*>(&raw_);
                                                   ^
    "\"".cc: In member function 'const glr_state& glr_stack_item::getState() const':
    "\"".cc:1408:53: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
         return *reinterpret_cast<const glr_state*>(&raw_);
                                                         ^
    "\"".cc: In member function 'semantic_option& glr_stack_item::getOption()':
    "\"".cc:1413:53: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
         return *reinterpret_cast<semantic_option*>(&raw_);
                                                         ^
    "\"".cc: In member function 'const semantic_option& glr_stack_item::getOption() const':
    "\"".cc:1417:59: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
         return *reinterpret_cast<const semantic_option*>(&raw_);
                                                           ^

See also be6fa942ac.

* data/skeletons/glr2.cc (glr_stack_item): Use a temporary void*
variable to avoid type-punning issues with reinterpret_cast.
2020-09-13 13:45:17 +02:00
Akim Demaille
952a61b62e glr.cc, glr2.cc: don't publish compiler pragmas
Currently the compiler attributes are defined in
b4_shared_declarations (that can in the header if it exists, otherwise
in the implementation file).  This is not needed, only the
implementation file needs them.

Besides, glr2.cc was also defining these macros in the implementation
file, so we had two definitions.

* data/skeletons/glr.cc, data/skeletons/glr2.cc: Define the compiler
attribute macros only in the implementation files.
* tests/regression.at (Lex and parse params): Generate a header, to
make it easy to check that the header is self-sufficient.
2020-09-13 12:23:13 +02:00
Akim Demaille
cf8f805d36 glr2.cc: disable incorrect warnings from GCC6 to 9
For instance with GCC8:

    616. regression.at:1560: testing Lex and parse params: glr2.cc ...
    tests/regression.at:1560: COLUMNS=1000; export COLUMNS; NO_TERM_HYPERLINKS=1; export NO_TERM_HYPERLINKS;  bison --color=no -fno-caret  -o input.cc input.y
    tests/regression.at:1560: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o input input.cc $LIBS
    stderr:
    input.cc: In member function 'YYRESULTTAG glr_stack::yyresolveValue(glr_state*)':
    input.cc:1796:10: error: potential null pointer dereference [-Werror=null-dereference]
       return yypred ? &(asItem(this) - yypred)->getState() : YY_NULLPTR;
              ^~~~~~
    input.cc:1796:10: error: potential null pointer dereference [-Werror=null-dereference]
       return yypred ? &(asItem(this) - yypred)->getState() : YY_NULLPTR;
              ^~~~~~
    cc1plus: all warnings being treated as errors

It complains that the implicit this in yypred might be null.  It fears
it because of loops such as

    for (glr_state* yys = firstTopState();
         yys != yystateStack.yysplitPoint;
         yys = yys->pred())
      yyn += 1;

that could possibly set yys to null, since yys->pred might return
null.  However, the warning is incorrect, since in C++ `this` cannot
be null.  GCC 10 no longer emits this warning.

GCC 7 also complains many times about glr_stack::yyresolveLocations
when NDEBUG is enabled (when it is not, YYASSERT (yyoption !=
YY_NULLPTR) is probably enough to pacify GCC):

    616. regression.at:1560: testing Lex and parse params: glr2.cc ...
    tests/regression.at:1560: COLUMNS=1000; export COLUMNS; NO_TERM_HYPERLINKS=1; export NO_TERM_HYPERLINKS;  bison --color=no -fno-caret  -o input.cc input.y
    tests/regression.at:1560: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o input input.cc $LIBS
    stderr:
    input.cc: In member function 'void glr_stack::yyresolveLocations(glr_state*, int)':
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    input.cc: In member function 'YYRESULTTAG glr_stack::yyresolveValue(glr_state*)':
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
    input.cc:3061:46: error: potential null pointer dereference [-Werror=null-dereference]
                     yyrhsloc[0].getState().yyloc = yyoption->state()->yyloc;
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

* data/skeletons/glr2.cc (YY_IGNORE_NULL_DEREFERENCE_BEGIN)
(YY_IGNORE_NULL_DEREFERENCE_BEGIN): New.
(glr_state::pred, glr_stack::yyresolveLocations): Use them.
2020-09-13 12:08:28 +02:00
Akim Demaille
b5e6d9c4ca glr2.cc: address warnings with G++ 4.8
input.cc: In constructor 'glr_stack_item::glr_stack_item(bool)':
input.cc:1423:5: error: declaration of 'isState' shadows a member of 'this' [-Werror=shadow]
     : isState_(isState) {
     ^
test.cc:1165:45: error: declaration of 'begin' shadows a member of 'this' [-Werror=shadow]
test.cc:1167:45: error: declaration of 'end' shadows a member of 'this' [-Werror=shadow]

* data/skeletons/glr2.cc (isState): Rename as...
(is_state): this.
Formatting changes.
(reduceToOneStack): Rename variables to avoid name clashes.
2020-09-12 15:23:19 +02:00
Akim Demaille
3ae2a22a05 glr2.cc: get rid of the C indirection for yy_symbol_print
* data/skeletons/glr2.cc (yy_symbol_print): Remove.
Just use yyparser.yy_symbol_print_ directly.
2020-09-12 14:49:05 +02:00
Akim Demaille
146a8eb101 glr2.cc: formatting changes
* data/skeletons/glr2.cc: here.
2020-09-12 14:44:29 +02:00
Akim Demaille
4428e8e8b3 glr2.cc: fix GCC10 warning
For instance on test 433: "glr2.cc api.value.type={double}"

    tests/types.at:138: $CXX $CXXFLAGS $CPPFLAGS  $LDFLAGS -o test test.cc $LIBS
    stderr:
    In file included from /opt/local/include/gcc10/c++/bits/stl_tempbuf.h:60,
                     from /opt/local/include/gcc10/c++/bits/stl_algo.h:62,
                     from /opt/local/include/gcc10/c++/algorithm:62,
                     from test.cc:82:
    /opt/local/include/gcc10/c++/bits/stl_construct.h: In instantiation of 'constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = glr_stack_item; _Args = {glr_stack_item}; decltype (::new(void*(0)) _Tp) = glr_stack_item*]':
    /opt/local/include/gcc10/c++/bits/alloc_traits.h:514:21:   required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = glr_stack_item; _Args = {glr_stack_item}; _Tp = glr_stack_item; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<glr_stack_item>]'
    /opt/local/include/gcc10/c++/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {glr_stack_item}; _Tp = glr_stack_item; _Alloc = std::allocator<glr_stack_item>; std::vector<_Tp, _Alloc>::reference = glr_stack_item&]'
    /opt/local/include/gcc10/c++/bits/stl_vector.h:1204:21:   required from 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = glr_stack_item; _Alloc = std::allocator<glr_stack_item>; std::vector<_Tp, _Alloc>::value_type = glr_stack_item]'
    test.cc:1949:48:   required from here
    /opt/local/include/gcc10/c++/bits/stl_construct.h:95:14: error: noexcept-expression evaluates to 'false' because of a call to 'glr_stack_item::glr_stack_item(const glr_stack_item&)' [-Werror=noexcept]
       95 |     noexcept(noexcept(::new((void*)0) _Tp(std::declval<_Args>()...)))
          |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    test.cc:1436:3: note: but 'glr_stack_item::glr_stack_item(const glr_stack_item&)' does not throw; perhaps it should be declared 'noexcept'
     1436 |   glr_stack_item(const glr_stack_item& other)
          |   ^~~~~~~~~~~~~~
    cc1plus: all warnings being treated as errors
    stdout:
    tests/types.at:138: exit code was 1, expected 0
    433. types.at:138: 433. glr2.cc api.value.type={double} (types.at:138): FAILED (types.at:138)

* data/skeletons/glr2.cc (glr_stack_item): Use YY_NOEXCEPT/YY_NOTHROW.
2020-09-12 14:44:27 +02:00
Valentin Tolmer
00e47b11d2 glr2.cc: coding style changes
* data/skeletons/glr2.cc: Change some CamlCase to snake_case, and
remove some yy prefixes for classes inside the namespace.
2020-09-12 14:11:58 +02:00
Valentin Tolmer
cf8723de0d glr2.cc: move StrongIndexAlias into the namespace
* data/skeletons/glr2.cc: here.
2020-09-12 14:11:40 +02:00
Valentin Tolmer
8bfc319f8e glr2.cc: remove usage of PTRDIFF_MAX
* data/skeletons/glr2.cc: Use std::ptrdiff_t and numeric_limits.
2020-09-12 14:11:00 +02:00
Valentin Tolmer
1c5b05ad31 glr2.cc: remove C-style casts
* data/skeletons/glr2.cc: here.
2020-09-12 14:10:21 +02:00
Valentin Tolmer
b7e2cac2aa glr2.cc: add copy constructor to yyGLRStackItem
This silences the clang warning -Wdeprecated-copy.

* data/skeletons/glr2.cc: here.
2020-09-12 14:10:02 +02:00
Akim Demaille
1df4b746da glr2.cc: style changes
* data/skeletons/glr2.cc: Remove stray comment.
2020-09-05 07:47:21 +02:00
Akim Demaille
f3f7f6e1dc glr2.cc: get rid of the yyerror scaffolding
The yyerror stand-alone function was used to bounce from glr.c's call
to yyerror to glr.cc's parser.error.  Now that glr.c is out of the
way, just directly use parser.error.

* data/skeletons/glr2.cc (yyerror): Remove.
Adjust callers.
(b4_yyerror_args, b4_lyyerror_args, b4_pure_formals): Remove.
Now unused.
2020-09-05 07:44:23 +02:00
Valentin Tolmer
38abe1e1b7 glr2.cc: avoid warnings about printf and shadowing
* data/skeletons/glr2.cc: Migrate from using printf to std::cerr & co.
Since the yyGLRStack has the user params, no need to pass them around.
2020-09-04 06:47:10 +02:00
Akim Demaille
82d913741b glr2.cc: avoid warnings about long long
* data/skeletons/glr2.cc: Disable the warning before triggering it.
2020-08-30 20:05:34 +02:00
Akim Demaille
b63e3a3352 glr2.cc: fix a few warnings
* data/skeletons/glr2.cc: Fix some documentation.
Be consistent between class/struct.
(yydoAction, yyresolveAction): Avoid passing yyparser where useless.
2020-08-30 12:58:27 +02:00
Valentin Tolmer
ef09bf065a glr2.cc: fork glr.cc to a c++ version
This is a fork of glr.cc to be c++-first instead of a wrapper around
glr.c.

* data/skeletons/glr2.cc: New.
* data/skeletons/bison.m4, data/skeletons/c++.m4: Adjust.
* data/skeletons/c.m4 (b4_user_args_no_comma): New.
* src/reader.c (grammar_rule_check_and_complete): glr2.cc is C++.
* tests/actions.at, tests/c++.at, tests/calc.at, tests/conflicts.at,
* tests/input.at, tests/local.at, tests/regression.at, tests/scanner.at,
* tests/synclines.at, tests/types.at: Also check glr2.cc.
2020-08-30 10:45:21 +02:00