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