[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: lalr1.cc: support move semantics
From: |
Akim Demaille |
Subject: |
Re: RFC: lalr1.cc: support move semantics |
Date: |
Wed, 12 Sep 2018 07:18:02 +0200 |
> Le 12 sept. 2018 à 07:06, Akim Demaille <address@hidden> a écrit :
>
> Here is my updated proposal.
>
> commit 4ba0a5eac0953e308128af23324103f9589dc37e
> Author: Akim Demaille <address@hidden>
> Date: Sun Aug 12 18:05:47 2018 +0200
>
> lalr1.cc: support move semantics
On top of which I propose this:
commit 838a76755d1c821dc253e34596b73f065661e0dc
Author: Akim Demaille <address@hidden>
Date: Mon Sep 10 20:01:48 2018 +0200
lalr1.cc: modern C++ no longer needs an assignment for symbols
Reported by Frank Heckenbach.
http://lists.gnu.org/archive/html/bug-bison/2018-03/msg00002.html
Actually the assignment operator should never be needed: the C++98
requirements for vector::push_back is CopyInsertable, which does not require
an assignment operator. However, libstdc++ shipped with GCC up to (and
including) 6 uses the assignment operator (which affects Clang on top of
libstdc++, but also ICC). So let's keep it for legacy C++.
See https://gcc.godbolt.org/z/q0XXmC.
* data/lalr1.cc (stack_symbol_type::operator=): Remove.
* data/c++.m4 (basic_symbol::operator=): Ditto.
* tests/c++.at (C++ Variant-based Symbols Unit Tests): Adjust.
diff --git a/data/c++.m4 b/data/c++.m4
index 32bf8254..4cf51d40 100644
--- a/data/c++.m4
+++ b/data/c++.m4
@@ -272,8 +272,10 @@ m4_define([b4_symbol_type_declare],
location_type location;])[
private:
+#if defined __cplusplus && __cplusplus < 201103L
/// Assignment operator.
basic_symbol& operator= (const basic_symbol& other);
+#endif
};
/// Type access provider for token (enum) based symbols.
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 239c242b..15fd6fb9 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -326,8 +326,10 @@ b4_location_define])])[
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);
- /// Assignment, needed by push_back.
+#if defined __cplusplus && __cplusplus < 201103L
+ /// Assignment, needed by push_back by some old implementations.
stack_symbol_type& operator= (YY_MOVE_REF (stack_symbol_type) that);
+#endif
};
/// Stack type.
@@ -608,6 +610,7 @@ m4_if(b4_prefix, [yy], [],
that.type = empty_symbol;
}
+#if defined __cplusplus && __cplusplus < 201103L
]b4_parser_class_name[::stack_symbol_type&
]b4_parser_class_name[::stack_symbol_type::operator= (YY_MOVE_REF
(stack_symbol_type) that)
{
@@ -618,6 +621,7 @@ m4_if(b4_prefix, [yy], [],
location = YY_MOVE (that.location);])[
return *this;
}
+#endif
template <typename Base>
void
diff --git a/tests/c++.at b/tests/c++.at
index 1b80063b..b92fe9e1 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -166,12 +166,12 @@ int main()
for (int i = 0; i < 100; ++i)
{
#if defined __cplusplus && 201103L <= __cplusplus
- auto ss = parser::stack_symbol_type(1, parser::make_INT(123));
+ st.push(parser::stack_symbol_type{1, parser::make_INT(123)});
#else
parser::symbol_type s = parser::make_INT(123);
parser::stack_symbol_type ss(1, s);
-#endif
st.push(ss);
+#endif
}
}
}
- RFC: lalr1.cc: support move semantics, Akim Demaille, 2018/09/09
- Re: RFC: lalr1.cc: support move semantics, Frank Heckenbach, 2018/09/11
- Re: RFC: lalr1.cc: support move semantics, Akim Demaille, 2018/09/11
- Re: RFC: lalr1.cc: support move semantics, Frank Heckenbach, 2018/09/11
- Re: RFC: lalr1.cc: support move semantics, Akim Demaille, 2018/09/12
- Re: RFC: lalr1.cc: support move semantics, Akim Demaille, 2018/09/12
- Re: RFC: lalr1.cc: support move semantics,
Akim Demaille <=
- Re: RFC: lalr1.cc: support move semantics, Hans Åberg, 2018/09/12
- Re: RFC: lalr1.cc: support move semantics, Frank Heckenbach, 2018/09/12
- Re: RFC: lalr1.cc: support move semantics, Hans Åberg, 2018/09/12
- Re: RFC: lalr1.cc: support move semantics, Frank Heckenbach, 2018/09/12
- Re: RFC: lalr1.cc: support move semantics, Hans Åberg, 2018/09/12
- Re: RFC: lalr1.cc: support move semantics, Hans Åberg, 2018/09/12
- Re: RFC: lalr1.cc: support move semantics, Akim Demaille, 2018/09/13
- Re: RFC: lalr1.cc: support move semantics, Hans Åberg, 2018/09/13
- Re: RFC: lalr1.cc: support move semantics, Frank Heckenbach, 2018/09/13
- Re: RFC: lalr1.cc: support move semantics, Akim Demaille, 2018/09/13