mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
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.
This commit is contained in:
10
data/c++.m4
10
data/c++.m4
@@ -53,8 +53,14 @@ m4_define([b4_inline],
|
||||
# b4_cxx_portability
|
||||
# ------------------
|
||||
m4_define([b4_cxx_portability],
|
||||
[// Support move semantics when possible.
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
[#if defined __cplusplus
|
||||
# define YY_CPLUSPLUS __cplusplus
|
||||
#else
|
||||
# define YY_CPLUSPLUS 199711L
|
||||
#endif
|
||||
|
||||
// Support move semantics when possible.
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
# define YY_MOVE std::move
|
||||
# define YY_MOVE_OR_COPY move
|
||||
# define YY_MOVE_REF(Type) Type&&
|
||||
|
||||
@@ -336,7 +336,7 @@ m4_define([b4_shared_declarations],
|
||||
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
|
||||
/// Steal the contents from \a sym to build this.
|
||||
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
|
||||
#if !defined __cplusplus || __cplusplus < 201103L
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Assignment, needed by push_back by some old implementations.
|
||||
/// Moves the contents of that.
|
||||
stack_symbol_type& operator= (stack_symbol_type& that);
|
||||
@@ -612,7 +612,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
{]b4_variant_if([
|
||||
b4_symbol_variant([that.type_get ()],
|
||||
[value], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
// that is emptied.
|
||||
that.state = empty_state;
|
||||
#endif
|
||||
@@ -627,7 +627,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
that.type = empty_symbol;
|
||||
}
|
||||
|
||||
#if !defined __cplusplus || __cplusplus < 201103L
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
]b4_parser_class_name[::stack_symbol_type&
|
||||
]b4_parser_class_name[::stack_symbol_type::operator= (stack_symbol_type& that)
|
||||
{
|
||||
@@ -685,7 +685,7 @@ m4_if(b4_prefix, [yy], [],
|
||||
void
|
||||
]b4_parser_class_name[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
|
||||
{
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
yypush_ (m, stack_symbol_type (s, std::move (sym)));
|
||||
#else
|
||||
stack_symbol_type ss (s, sym);
|
||||
|
||||
@@ -125,7 +125,7 @@ m4_define([b4_variant_define],
|
||||
return *new (yyas_<T> ()) T ();
|
||||
}
|
||||
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
/// Instantiate a \a T in here from \a t.
|
||||
template <typename T, typename U>
|
||||
T&
|
||||
@@ -213,7 +213,7 @@ m4_define([b4_variant_define],
|
||||
void
|
||||
move (self_type& other)
|
||||
{
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
emplace<T> (std::move (other.as<T> ()));
|
||||
# else
|
||||
emplace<T> ();
|
||||
@@ -222,7 +222,7 @@ m4_define([b4_variant_define],
|
||||
other.destroy<T> ();
|
||||
}
|
||||
|
||||
# if defined __cplusplus && 201103L <= __cplusplus
|
||||
# if 201103L <= YY_CPLUSPLUS
|
||||
/// Move the content of \a other to this.
|
||||
template <typename T>
|
||||
void
|
||||
|
||||
@@ -317,6 +317,7 @@ AT_CHECK([[$PERL -n -0777 -e '
|
||||
|YYUSE
|
||||
|YY_ATTRIBUTE(?:_PURE|_UNUSED)?
|
||||
|YY_COPY
|
||||
|YY_CPLUSPLUS
|
||||
|YY_IGNORE_MAYBE_UNINITIALIZED_(?:BEGIN|END)
|
||||
|YY_INITIAL_VALUE
|
||||
|YY_MOVE
|
||||
|
||||
Reference in New Issue
Block a user