[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regression in Bison 3.2 with variant semantic values in C++ parsers
From: |
Akim Demaille |
Subject: |
Re: Regression in Bison 3.2 with variant semantic values in C++ parsers |
Date: |
Tue, 20 Nov 2018 19:45:55 +0100 |
The patch below should fix the bug. I’m really sorry about it.
Please, confirm that this tarball does work for you. Then I’ll
release it.
https://www.lrde.epita.fr/~akim/private/bison/bison-3.2.1.9-1e55d.tar.gz
https://www.lrde.epita.fr/~akim/private/bison/bison-3.2.1.9-1e55d.tar.xz
It is currently in the ‘maint’ branch. This branch is forked
from v3.2.1, and cherry-picked the following commits from master
(see bison-patches) from older to newer:
commit 554a12102ea1185decdb05d11c7e3ba442f23955
Author: Akim Demaille <address@hidden>
Date: Fri Nov 9 06:51:46 2018 +0100
maint: post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
commit 27313321506959d97e136650db14ad7b2db20e5b
Author: Akim Demaille <address@hidden>
Date: Sun Nov 11 19:28:40 2018 +0100
tests: fix syncline tests
These tests are skipped with GCC:
"\"".c:1:5: error: function declaration isn't a prototype
[-Werror=strict-prototypes]
int main() { return 0; }
^~~~
* tests/synclines.at: Stop writing C++ in C.
* tests/local.at: Formatting changes.
commit bf7abf4849657285e848d69dbda5836b6af945a3
Author: Akim Demaille <address@hidden>
Date: Mon Nov 12 08:42:34 2018 +0100
tests: compile the C++ examples with warnings
* examples/c++/local.mk: Pass $(WARN_CXXFLAGS_TEST).
commit c03d0d9625922d87c0fa90f3cc2cbf1e12b38479
Author: Akim Demaille <address@hidden>
Date: Tue Nov 13 06:49:24 2018 +0100
c++: factor the handling of __cplusplus into YY_CPLUSPLUS
* data/c++.m4 (b4_cxx_portability): Define it.
Use it.
* data/lalr1.cc, data/variant.hh: Use it.
commit 33c788d37ba300578f0f01c7e5b27eeb21cd9588
Author: Akim Demaille <address@hidden>
Date: Wed Nov 14 18:05:41 2018 +0100
c++: use YY_CPLUSPLUS
* data/c++.m4: here.
commit 2e053317c89e93f950061eb647c193ceaaaea936
Author: Akim Demaille <address@hidden>
Date: Fri Nov 16 08:56:12 2018 +0100
CI: split the ASAN job in two
The following commit introduce even more compilations/runs than
before, and with ASAN on, we go beyond to 50min credit from Travis.
* .travis.yml (Clang 7 libc++ and ASAN): Split in two.
commit 0360a35228f8cd622d97c377120b39d222e56c5e
Author: Akim Demaille <address@hidden>
Date: Wed Nov 14 21:03:18 2018 +0100
tests: run the api.value.type tests for all C++ standards
* tests/local.at (AT_LANG_FOR_EACH_STD): New.
(AT_REQUIRE_CXX_VERSION): Rename as...
(AT_REQUIRE_CXX_STD): this.
Accept an argument for what to do when the requirement is not met.
* tests/types.at (api.value.type): Check all the C++ stds.
commit 2eb1ad9ef3d9f502dcf03831da4d862e2a0b159b
Author: Akim Demaille <address@hidden>
Date: Wed Nov 14 21:23:11 2018 +0100
glr.c: fix use of _Noreturn
In C++, [[noreturn]] must not be between "static" and the rest of the
function signature, it must precede it. C's _Noreturn does not seem
to have such a constraint, but it is therefore compatible with the C++
constraint. Since we #define _Noreturn as [[noreturn]] is modern C++,
be sure to push the _Noreturn first.
Unfortunately this was not caught by the test suite, because it always
loads config.h first, and config.h contains another definition of
_Noreturn that does not use [[noreturn]], and hides ours. That's
probably a sign we should avoid always loading config.h.
* data/glr.c (yyFail, yyMemoryExhausted): here.
commit 1e55dab2fd1fbf1e17df8ef8947df6adc8c3f391
Author: Akim Demaille <address@hidden>
Date: Tue Nov 20 19:28:12 2018 +0100
c++: using macros around user types breaks when they include comma
We may generate code such as
basic_symbol (typename Base::kind_type t, YY_RVREF (std::pair<int,int>)
v);
which, of course, breaks, because YY_RVREF sees two arguments. Let's
not play tricks with _VA_ARGS__, I'm unsure about it portability.
Anyway, I plan to change more things in this area.
Reported by Sébastien Villemot.
http://lists.gnu.org/archive/html/bug-bison/2018-11/msg00014.html
* data/variant.hh (b4_basic_symbol_constructor_declare)
(b4_basic_symbol_constructor_define): Don't use macro on user types.
* tests/types.at: Check that we support pairs.
=============================================================
commit 1e55dab2fd1fbf1e17df8ef8947df6adc8c3f391
Author: Akim Demaille <address@hidden>
Date: Tue Nov 20 19:28:12 2018 +0100
c++: using macros around user types breaks when they include comma
We may generate code such as
basic_symbol (typename Base::kind_type t, YY_RVREF (std::pair<int,int>)
v);
which, of course, breaks, because YY_RVREF sees two arguments. Let's
not play tricks with _VA_ARGS__, I'm unsure about it portability.
Anyway, I plan to change more things in this area.
Reported by Sébastien Villemot.
http://lists.gnu.org/archive/html/bug-bison/2018-11/msg00014.html
* data/variant.hh (b4_basic_symbol_constructor_declare)
(b4_basic_symbol_constructor_define): Don't use macro on user types.
* tests/types.at: Check that we support pairs.
diff --git a/THANKS b/THANKS
index e564cf22..3d61e148 100644
--- a/THANKS
+++ b/THANKS
@@ -151,6 +151,7 @@ Roland Levillain address@hidden
Satya Kiran Popuri address@hidden
Sebastian Setzer address@hidden
Sebastien Fricker address@hidden
+Sébastien Villemot address@hidden
Sergei Steshenko address@hidden
Shura address@hidden
Simon Sobisch address@hidden
diff --git a/data/variant.hh b/data/variant.hh
index 805ddce0..2e0ac139 100644
--- a/data/variant.hh
+++ b/data/variant.hh
@@ -379,26 +379,44 @@ b4_join(b4_symbol_if([$1], [has_type],
# -----------------------------------
# Generate a constructor declaration for basic_symbol from given type.
m4_define([b4_basic_symbol_constructor_declare],
-[[ basic_symbol (]b4_join(
+[[# if 201103L <= YY_CPLUSPLUS
+ basic_symbol (]b4_join(
[typename Base::kind_type t],
- b4_symbol_if([$1], [has_type], [YY_RVREF (b4_symbol([$1], [type]))
v]),
- b4_locations_if([YY_RVREF (location_type) l]))[);
+ b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
+ b4_locations_if([location_type&& l]))[);
+#else
+ basic_symbol (]b4_join(
+ [typename Base::kind_type t],
+ b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]),
+ b4_locations_if([const location_type& l]))[);
+#endif
]])
# b4_basic_symbol_constructor_define
# ----------------------------------
# Generate a constructor implementation for basic_symbol from given type.
m4_define([b4_basic_symbol_constructor_define],
-[[ template <typename Base>
+[[# if 201103L <= YY_CPLUSPLUS
+ template <typename Base>
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::kind_type t],
- b4_symbol_if([$1], [has_type], [YY_RVREF (b4_symbol([$1], [type]))
v]),
- b4_locations_if([YY_RVREF (location_type) l]))[)
+ b4_symbol_if([$1], [has_type], [b4_symbol([$1], [type])&& v]),
+ b4_locations_if([location_type&& l]))[)
: Base (t)]b4_symbol_if([$1], [has_type], [
- , value (YY_MOVE (v))])[]b4_locations_if([
- , location (YY_MOVE (l))])[
+ , value (std::move (v))])[]b4_locations_if([
+ , location (std::move (l))])[
{}
-
+#else
+ template <typename Base>
+ ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
+ [typename Base::kind_type t],
+ b4_symbol_if([$1], [has_type], [const b4_symbol([$1], [type])& v]),
+ b4_locations_if([const location_type& l]))[)
+ : Base (t)]b4_symbol_if([$1], [has_type], [
+ , value (v)])[]b4_locations_if([
+ , location (l)])[
+ {}
+#endif
]])
# b4_symbol_constructor_define
diff --git a/tests/types.at b/tests/types.at
index 84d3e222..2c50b2bb 100644
--- a/tests/types.at
+++ b/tests/types.at
@@ -270,6 +270,24 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc],
[glr.cc]],
AT_VAL.build<std::string> ("two");],
[10, two])
+ # Test a regression where we passed user types (we can include
+ # commas) to a CPP macro.
+ AT_TEST([%skeleton "]b4_skel["
+ %define api.value.type variant],
+ [%token <std::pair<int, int>> '1';
+ %token <std::pair<std::string, std::string>> '2';],
+ ['1' '2'
+ {
+ std::cout << $1.first << ':' << $1.second << ", "
+ << $2.first << ':' << $2.second << '\n';
+ }],
+ ["12"],
+ [if (res == '1')
+ AT_VAL.build (std::make_pair(10, 11));
+ else if (res == '2')
+ AT_VAL.build (std::make_pair<std::string, std::string> ("two",
"deux"));],
+ [10:11, two:deux])
+
# Move-only types.
AT_TEST([%skeleton "]b4_skel["
%code requires { #include <memory> }