mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
Don't memcpy C++ structures.
* data/lalr1-fusion.cc (b4_symbol_variant): Adjust additional arguments. (variant::build): New overload for copy-construction-that-destroys. (variant::swap): New. (parser::yypush_): Use it in variant mode.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
2008-11-04 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
Don't memcpy C++ structures.
|
||||||
|
* data/lalr1-fusion.cc (b4_symbol_variant): Adjust additional
|
||||||
|
arguments.
|
||||||
|
(variant::build): New overload for
|
||||||
|
copy-construction-that-destroys.
|
||||||
|
(variant::swap): New.
|
||||||
|
(parser::yypush_): Use it in variant mode.
|
||||||
|
|
||||||
2008-11-04 Akim Demaille <demaille@gostai.com>
|
2008-11-04 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
Better defaults for bench.pl.
|
Better defaults for bench.pl.
|
||||||
|
|||||||
@@ -85,13 +85,13 @@ m4_define([b4_symbol_action_],
|
|||||||
])])
|
])])
|
||||||
|
|
||||||
|
|
||||||
# b4_symbol_variant(YYTYPE, YYVAL, ACTION)
|
# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
|
||||||
# ----------------------------------------
|
# ------------------------------------------------
|
||||||
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
|
# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
|
||||||
# YYTYPE.
|
# YYTYPE.
|
||||||
m4_define([b4_symbol_variant],
|
m4_define([b4_symbol_variant],
|
||||||
[m4_pushdef([b4_dollar_dollar],
|
[m4_pushdef([b4_dollar_dollar],
|
||||||
[$2.$3<$][3>()])dnl
|
[$2.$3<$][3>(m4_shift3($@))])dnl
|
||||||
switch ($1)
|
switch ($1)
|
||||||
{
|
{
|
||||||
m4_map([b4_symbol_action_], m4_defn([b4_type_names]))
|
m4_map([b4_symbol_action_], m4_defn([b4_type_names]))
|
||||||
@@ -202,6 +202,24 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
return reinterpret_cast<const T&>(buffer);
|
return reinterpret_cast<const T&>(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Swap the content with \a other.
|
||||||
|
template <typename T>
|
||||||
|
inline void
|
||||||
|
swap(variant<S>& other)
|
||||||
|
{
|
||||||
|
std::swap(as<T>(), other.as<T>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assign the content of \a other to this.
|
||||||
|
/// Destroys \a other.
|
||||||
|
template <typename T>
|
||||||
|
inline void
|
||||||
|
build(variant<S>& other)
|
||||||
|
{
|
||||||
|
build<T>();
|
||||||
|
swap<T>(other);
|
||||||
|
}
|
||||||
|
|
||||||
/// Destroy the stored \a T.
|
/// Destroy the stored \a T.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void
|
inline void
|
||||||
@@ -683,7 +701,10 @@ do { \
|
|||||||
]b4_parser_class_name[::yypush_ (state_type s,
|
]b4_parser_class_name[::yypush_ (state_type s,
|
||||||
semantic_type& v, const location_type& l)
|
semantic_type& v, const location_type& l)
|
||||||
{
|
{
|
||||||
yystack_.push (data_type (s, v, l));
|
]b4_variant_if(
|
||||||
|
[[ yystack_.push (data_type (s, semantic_type(), l));
|
||||||
|
]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]], [build], [v])],
|
||||||
|
[ yystack_.push (data_type (s, v, l));])[
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user