[PATCH 1/9] glr2.cc: add copy constructor to yyGLRStackItem
Akim Demaille <[email protected]>
| Newsgroups | gmane.comp.parsers.bison.patches |
|---|---|
| Message-ID | <[email protected]> |
From: Valentin Tolmer <[email protected]> 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