Anthony,

Thanks for the suggestion, the patience, and for the patch.  I'm installing the 
following edited version of your commit.  It is "trivial" enough to not need 
FSF paperwork.

Frank:

> BTW, when checking this, I noticed there's a "void move" function
> declared (actually 3 of them for different classes) in the skeletons
> which I thought were involved here, but there doesn't seem to be any
> definition of them. So these declarations may be remnants, and you
> might want to remove them, Akim.


These functions are not C++ standard, they participate in Bison's effort to 
have some form of move semantics in C98.

Cheers!

commit eb83487606276fdefd20415176aff9309a62a5ee
Author: Anthony Heading <a...@ajrh.net>
Date:   Fri Apr 29 04:08:35 2022 -0400

    c++: enable C++11 assignment operators for lalr1.cc
    
    <https://github.com/akimd/bison/pull/85>
    <https://lists.gnu.org/r/bug-bison/2022-04/msg00000.html>
    
    * data/skeletons/c++.m4: Enable C++11 assignment operators for
    all C++ skeletons.

diff --git a/NEWS b/NEWS
index aabca967..f480cb95 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ GNU Bison NEWS
 
   Fixed spurious warnings about input containing `m4_` or `b4_`.
 
+  The C++ skeletons now expose copy and move operators for symbols.
+
 * Noteworthy changes in release 3.8.2 (2021-09-25) [stable]
 
   Fixed portability issues of bison on Cygwin.
diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index 78f71fce..d63d1548 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -346,7 +346,7 @@ m4_define([b4_symbol_type_define],
         clear ();
       }
 
-]b4_glr2_cc_if([[
+#if 201103L <= YY_CPLUSPLUS
       /// Copy assignment.
       basic_symbol& operator= (const basic_symbol& that)
       {
@@ -368,7 +368,7 @@ m4_define([b4_symbol_type_define],
         location = std::move (that.location);]])[
         return *this;
       }
-]])[
+#endif
 
       /// Destroy contents, and record that is empty.
       void clear () YY_NOEXCEPT
@@ -454,13 +454,13 @@ m4_define([b4_symbol_type_define],
       /// Constructor from (external) token numbers.
       by_kind (kind_type t) YY_NOEXCEPT;
 
-]b4_glr2_cc_if([[
+#if 201103L <= YY_CPLUSPLUS
       /// Copy assignment.
       by_kind& operator= (const by_kind& that);
 
       /// Move assignment.
       by_kind& operator= (by_kind&& that);
-]])[
+#endif
 
       /// Record that this symbol is empty.
       void clear () YY_NOEXCEPT;
@@ -584,7 +584,7 @@ m4_define([b4_public_types_define],
     : kind_ (yytranslate_ (t))
   {}
 
-]b4_glr2_cc_if([[
+#if 201103L <= YY_CPLUSPLUS
   ]b4_inline([$1])]b4_parser_class[::by_kind&
   b4_parser_class[::by_kind::by_kind::operator= (const by_kind& that)
   {
@@ -599,7 +599,7 @@ m4_define([b4_public_types_define],
     that.clear ();
     return *this;
   }
-]])[
+#endif
 
   ]b4_inline([$1])[void
   ]b4_parser_class[::by_kind::clear () YY_NOEXCEPT


Reply via email to