mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
c++: use modern idioms to make classes non-copyable
Reported by Don Macpherson. https://lists.gnu.org/r/bug-bison/2019-05/msg00015.html https://github.com/akimd/bison/issues/36 * data/skeletons/lalr1.cc, data/skeletons/stack.hh, * data/skeletons/variant.hh: Delete the copy-ctor and the copy operator.
This commit is contained in:
1
THANKS
1
THANKS
@@ -57,6 +57,7 @@ Derek M. Jones derek@knosof.co.uk
|
|||||||
Di-an Jan dianj@freeshell.org
|
Di-an Jan dianj@freeshell.org
|
||||||
Dick Streefland dick.streefland@altium.nl
|
Dick Streefland dick.streefland@altium.nl
|
||||||
Didier Godefroy dg@ulysium.net
|
Didier Godefroy dg@ulysium.net
|
||||||
|
Don Macpherson donmac703@gmail.com
|
||||||
Efi Fogel efifogel@gmail.com
|
Efi Fogel efifogel@gmail.com
|
||||||
Enrico Scholz enrico.scholz@informatik.tu-chemnitz.de
|
Enrico Scholz enrico.scholz@informatik.tu-chemnitz.de
|
||||||
Eric Blake ebb9@byu.net
|
Eric Blake ebb9@byu.net
|
||||||
|
|||||||
@@ -204,6 +204,13 @@ m4_define([b4_shared_declarations],
|
|||||||
]b4_parser_class[ (]b4_parse_param_decl[);
|
]b4_parser_class[ (]b4_parse_param_decl[);
|
||||||
virtual ~]b4_parser_class[ ();
|
virtual ~]b4_parser_class[ ();
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Non copyable.
|
||||||
|
]b4_parser_class[ (const ]b4_parser_class[&) = delete;
|
||||||
|
/// Non copyable.
|
||||||
|
]b4_parser_class[& operator= (const ]b4_parser_class[&) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Parse. An alias for parse ().
|
/// Parse. An alias for parse ().
|
||||||
/// \returns 0 iff parsing succeeded.
|
/// \returns 0 iff parsing succeeded.
|
||||||
int operator() ();
|
int operator() ();
|
||||||
@@ -255,10 +262,13 @@ m4_define([b4_shared_declarations],
|
|||||||
};
|
};
|
||||||
]])[
|
]])[
|
||||||
private:
|
private:
|
||||||
/// This class is not copyable.
|
#if YY_CPLUSPLUS < 201103L
|
||||||
|
/// Non copyable.
|
||||||
]b4_parser_class[ (const ]b4_parser_class[&);
|
]b4_parser_class[ (const ]b4_parser_class[&);
|
||||||
]b4_parser_class[& operator= (const ]b4_parser_class[&);]b4_lac_if([[
|
/// Non copyable.
|
||||||
|
]b4_parser_class[& operator= (const ]b4_parser_class[&);
|
||||||
|
#endif
|
||||||
|
]b4_lac_if([[
|
||||||
/// Check the lookahead yytoken.
|
/// Check the lookahead yytoken.
|
||||||
/// \returns true iff the token will be eventually shifted.
|
/// \returns true iff the token will be eventually shifted.
|
||||||
bool yy_lac_check_ (symbol_kind_type yytoken) const;
|
bool yy_lac_check_ (symbol_kind_type yytoken) const;
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ m4_define([b4_stack_define],
|
|||||||
: seq_ (n)
|
: seq_ (n)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Non copyable.
|
||||||
|
stack (const stack&) = delete;
|
||||||
|
/// Non copyable.
|
||||||
|
stack& operator= (const stack&) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Random access.
|
/// Random access.
|
||||||
///
|
///
|
||||||
/// Index 0 returns the topmost element.
|
/// Index 0 returns the topmost element.
|
||||||
@@ -126,8 +133,12 @@ m4_define([b4_stack_define],
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if YY_CPLUSPLUS < 201103L
|
||||||
|
/// Non copyable.
|
||||||
stack (const stack&);
|
stack (const stack&);
|
||||||
|
/// Non copyable.
|
||||||
stack& operator= (const stack&);
|
stack& operator= (const stack&);
|
||||||
|
#endif
|
||||||
/// The wrapped container.
|
/// The wrapped container.
|
||||||
S seq_;
|
S seq_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -115,6 +115,13 @@ m4_define([b4_value_type_declare],
|
|||||||
new (yyas_<T> ()) T (YY_MOVE (t));
|
new (yyas_<T> ()) T (YY_MOVE (t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
|
/// Non copyable.
|
||||||
|
semantic_type (const self_type&) = delete;
|
||||||
|
/// Non copyable.
|
||||||
|
self_type& operator= (const self_type&) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Destruction, allowed only if empty.
|
/// Destruction, allowed only if empty.
|
||||||
~semantic_type () YY_NOEXCEPT
|
~semantic_type () YY_NOEXCEPT
|
||||||
{]b4_parse_assert_if([
|
{]b4_parse_assert_if([
|
||||||
@@ -258,9 +265,12 @@ m4_define([b4_value_type_declare],
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prohibit blind copies.
|
#if YY_CPLUSPLUS < 201103L
|
||||||
self_type& operator= (const self_type&);
|
/// Non copyable.
|
||||||
semantic_type (const self_type&);
|
semantic_type (const self_type&);
|
||||||
|
/// Non copyable.
|
||||||
|
self_type& operator= (const self_type&);
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Accessor to raw memory as \a T.
|
/// Accessor to raw memory as \a T.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|||||||
Reference in New Issue
Block a user