[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
- [PATCH 0/9] glr2.cc: warnings and style, Akim Demaille, 2020/09/12
- [PATCH 1/9] glr2.cc: add copy constructor to yyGLRStackItem,
Akim Demaille <=
- [PATCH 2/9] glr2.cc: remove C-style casts, Akim Demaille, 2020/09/12
- [PATCH 3/9] glr2.cc: remove usage of PTRDIFF_MAX, Akim Demaille, 2020/09/12
- [PATCH 4/9] glr2.cc: move StrongIndexAlias into the namespace, Akim Demaille, 2020/09/12
- [PATCH 5/9] glr2.cc: coding style changes, Akim Demaille, 2020/09/12
- [PATCH 6/9] glr2.cc: fix GCC10 warning, Akim Demaille, 2020/09/12
- [PATCH 7/9] glr2.cc: formatting changes, Akim Demaille, 2020/09/12
- [PATCH 8/9] glr2.cc: get rid of the C indirection for yy_symbol_print, Akim Demaille, 2020/09/12
- [PATCH 9/9] glr2.cc: address warnings with G++ 4.8, Akim Demaille, 2020/09/12