bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/9] glr2.cc: add copy constructor to yyGLRStackItem


From: Akim Demaille
Subject: [PATCH 1/9] glr2.cc: add copy constructor to yyGLRStackItem
Date: Sat, 12 Sep 2020 16:51:47 +0200

From: Valentin Tolmer <valentin.tolmer@gmail.com>

This silences the clang warning -Wdeprecated-copy.

* data/skeletons/glr2.cc: here.
---
 data/skeletons/glr2.cc | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 987ac2e4..f115dcc0 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -127,6 +127,7 @@ m4_define([b4_shared_declarations],
 b4_percent_code_get([[requires]])[
 #include <algorithm>
 #include <cstddef> // ptrdiff_t
+#include <cstring> // memcpy
 #include <iostream>
 #include <iomanip>
 #include <stdexcept>
@@ -1239,6 +1240,18 @@ struct yyGLRStackItem {
       }
   }
 
+  yyGLRStackItem(const yyGLRStackItem& other)
+    : isState_(other.isState_) {
+    std::memcpy(raw_, other.raw_, union_size);
+  }
+
+  yyGLRStackItem& operator=(yyGLRStackItem other)
+  {
+    std::swap(isState_, other.isState_);
+    std::swap(raw_, other.raw_);
+    return *this;
+  }
+
   ~yyGLRStackItem() {
     if (isState()) {
       getState().~yyGLRState();
-- 
2.28.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]