mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-08-11 11:45:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8adec9c125 | ||
|
|
cafa811a66 | ||
|
|
07a187c5ee | ||
|
|
a81bcbb245 | ||
|
|
96ef81cf07 | ||
|
|
fc54e6b9b3 |
+1
-1
@@ -1 +1 @@
|
||||
3.2.2
|
||||
3.2.3
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
GNU Bison NEWS
|
||||
|
||||
* Noteworthy changes in release 3.2.4 (2018-12-24) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
Fix the move constructor of symbol_type.
|
||||
|
||||
Always provide a copy constructor for symbol_type, even in modern C++.
|
||||
|
||||
* Noteworthy changes in release 3.2.3 (2018-12-18) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
@@ -179,6 +179,7 @@ Wayne Green [email protected]
|
||||
Wei Song [email protected]
|
||||
Wojciech Polak [email protected]
|
||||
Wolfgang S. Kechel [email protected]
|
||||
Wolfgang Thaller [email protected]
|
||||
Wolfram Wagner [email protected]
|
||||
Wwp [email protected]
|
||||
xolodho [email protected]
|
||||
|
||||
+42
-12
@@ -244,8 +244,13 @@ m4_define([b4_symbol_type_declare],
|
||||
/// Default constructor.
|
||||
basic_symbol ();
|
||||
|
||||
/// Move or copy constructor.
|
||||
basic_symbol (YY_RVREF (basic_symbol) other);
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
basic_symbol (basic_symbol&& that);
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
basic_symbol (const basic_symbol& that);
|
||||
|
||||
]b4_variant_if([[
|
||||
/// Constructor for valueless symbols, and symbols from each type.
|
||||
@@ -280,7 +285,7 @@ m4_define([b4_symbol_type_declare],
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Assignment operator.
|
||||
basic_symbol& operator= (const basic_symbol& other);
|
||||
basic_symbol& operator= (const basic_symbol& that);
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -290,8 +295,13 @@ m4_define([b4_symbol_type_declare],
|
||||
/// Default constructor.
|
||||
by_type ();
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
/// Move constructor.
|
||||
by_type (by_type&& that);
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
by_type (const by_type& other);
|
||||
by_type (const by_type& that);
|
||||
|
||||
/// The symbol type as needed by the constructor.
|
||||
typedef token_type kind_type;
|
||||
@@ -339,14 +349,26 @@ m4_define([b4_public_types_define],
|
||||
, location ()])[
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
template <typename Base>
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (YY_RVREF (basic_symbol) other)
|
||||
: Base (YY_MOVE (other))
|
||||
, value (]b4_variant_if([], [YY_MOVE (other.value)]))b4_locations_if([
|
||||
, location (YY_MOVE (other.location))])[
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (basic_symbol&& that)
|
||||
: Base (std::move (that))
|
||||
, value (]b4_variant_if([], [std::move (that.value)]))b4_locations_if([
|
||||
, location (std::move (that.location))])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([other.type_get ()], [value], [YY_MOVE_OR_COPY],
|
||||
[YY_MOVE (other.value)])])[
|
||||
b4_symbol_variant([this->type_get ()], [value], [move],
|
||||
[std::move (that.value)])])[
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename Base>
|
||||
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
||||
: Base (that)
|
||||
, value (]b4_variant_if([], [that.value]))b4_locations_if([
|
||||
, location (that.location)])[
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([this->type_get ()], [value], [copy],
|
||||
[that.value])])[
|
||||
}
|
||||
|
||||
]b4_variant_if([[
|
||||
@@ -423,8 +445,16 @@ m4_define([b4_public_types_define],
|
||||
: type (empty_symbol)
|
||||
{}
|
||||
|
||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& other)
|
||||
: type (other.type)
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (by_type&& that)
|
||||
: type (that.type)
|
||||
{
|
||||
that.clear ();
|
||||
}
|
||||
#endif
|
||||
|
||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (const by_type& that)
|
||||
: type (that.type)
|
||||
{}
|
||||
|
||||
]b4_inline([$1])b4_parser_class_name[::by_type::by_type (token_type t)
|
||||
|
||||
+39
-13
@@ -103,7 +103,7 @@ AT_KEYWORDS([variant])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %debug $1])
|
||||
# Store strings and integers in a vector of strings.
|
||||
AT_DATA_GRAMMAR([list.y],
|
||||
AT_DATA_GRAMMAR([list.yy],
|
||||
[[%skeleton "lalr1.cc"
|
||||
%define api.value.type variant
|
||||
%define parse.assert
|
||||
@@ -142,24 +142,52 @@ exp: "int" { $$.push_back ($1); }
|
||||
]AT_YYERROR_DEFINE[
|
||||
]AT_YYLEX_DEFINE[
|
||||
|
||||
template <typename Exp, typename Eff>
|
||||
void assert_eq (const Exp& exp, const Eff& eff)
|
||||
{
|
||||
if (getenv ("DEBUG"))
|
||||
std::cerr << "Assert: " << exp << " == " << eff << '\n';
|
||||
if (exp != eff)
|
||||
std::cerr << "Assertion failed: " << exp << " != " << eff << '\n';
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using yy::parser;
|
||||
// symbol_type: construction, accessor.
|
||||
{
|
||||
parser::symbol_type s = parser::make_INT(12);
|
||||
std::cerr << s.value.as<int>() << '\n';
|
||||
parser::symbol_type s = parser::make_INT (12);
|
||||
assert_eq (s.value.as<int> (), 12);
|
||||
}
|
||||
|
||||
// symbol_type: move constructor.
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
{
|
||||
auto s = parser::make_INT (42);
|
||||
auto s2 = std::move (s);
|
||||
assert_eq (s2.value.as<int> (), 42);
|
||||
// Used to crash here, because s was improperly cleared, and
|
||||
// its destructor tried to delete its (moved) value.
|
||||
}
|
||||
#endif
|
||||
|
||||
// symbol_type: copy constructor.
|
||||
{
|
||||
parser::symbol_type s = parser::make_INT (51);
|
||||
parser::symbol_type s2 = s;
|
||||
assert_eq (s.value.as<int> (), 51);
|
||||
assert_eq (s2.value.as<int> (), 51);
|
||||
}
|
||||
|
||||
// stack_symbol_type: construction, accessor.
|
||||
{
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
auto ss = parser::stack_symbol_type(1, parser::make_INT(123));
|
||||
#else
|
||||
parser::symbol_type s = parser::make_INT(123);
|
||||
parser::symbol_type s = parser::make_INT (123);
|
||||
parser::stack_symbol_type ss(1, s);
|
||||
#endif
|
||||
std::cerr << ss.value.as<int>() << '\n';
|
||||
assert_eq (ss.value.as<int> (), 123);
|
||||
}
|
||||
|
||||
// Pushing on the stack.
|
||||
@@ -170,7 +198,7 @@ int main()
|
||||
const int mucho = 1700;
|
||||
for (int i = 0; i < mucho; ++i)
|
||||
{
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
st.push(parser::stack_symbol_type{1, parser::make_INT (i)});
|
||||
#else
|
||||
parser::symbol_type s = parser::make_INT (i);
|
||||
@@ -180,19 +208,17 @@ int main()
|
||||
}
|
||||
for (int i = mucho - 1; 0 <= i; --i)
|
||||
{
|
||||
assert (st[0].value.as<int>() == i);
|
||||
assert_eq (st[0].value.as<int>(), i);
|
||||
st.pop ();
|
||||
}
|
||||
}
|
||||
}
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[-o list.cc list.yy]])
|
||||
AT_FOR_EACH_CXX([
|
||||
AT_FULL_COMPILE([list])
|
||||
AT_PARSER_CHECK([./list], 0, [],
|
||||
[12
|
||||
123
|
||||
])
|
||||
AT_COMPILE_CXX([list])
|
||||
AT_PARSER_CHECK([./list])
|
||||
])
|
||||
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
|
||||
Reference in New Issue
Block a user