mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 23:33:03 +00:00
variants: prohibit simple copies
The "variant" structure provides a means to store, in a typeless way, C++ objects. Manipulating it without provide the type of the stored content is doomed to failure. So provide a means to copy in a type safe way, and prohibit typeless assignments. * data/c++.m4 (symbol_type::move): New. * data/lalr1.cc: Use it. * data/variant.hh (b4_variant_define): Provide variant::copy. Let variant::operator= abort. We cannot undefine it, yet, as it is still uses by the implicit assigment in symbols, which must also be disabled.
This commit is contained in:
13
data/c++.m4
13
data/c++.m4
@@ -185,6 +185,9 @@ m4_define([b4_public_types_declare],
|
||||
/// Default constructor.
|
||||
inline symbol_type ();
|
||||
|
||||
/// Destructive move, \a s is emptied.
|
||||
inline void move (symbol_type& s);
|
||||
|
||||
/// Constructor for tokens with semantic value.
|
||||
inline symbol_type (]b4_join([token_type t],
|
||||
[const semantic_type& v],
|
||||
@@ -294,6 +297,16 @@ m4_define([b4_public_types_define],
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
]b4_parser_class_name[::symbol_type::move (symbol_type& s)
|
||||
{
|
||||
]b4_variant_if([b4_symbol_variant([[s.type]], [value], [build], [s.value])],
|
||||
[value = s.value;])[
|
||||
type = s.type;]b4_locations_if([
|
||||
location = s.location;])[
|
||||
}
|
||||
|
||||
inline
|
||||
int
|
||||
]b4_parser_class_name[::symbol_type::type_get_ () const
|
||||
|
||||
Reference in New Issue
Block a user