glr2.cc: add copy constructor to yyGLRStackItem

This silences the clang warning -Wdeprecated-copy.

* data/skeletons/glr2.cc: here.
This commit is contained in:
Valentin Tolmer
2020-09-09 16:43:22 +02:00
committed by Akim Demaille
parent 93d6a5ba4d
commit b7e2cac2aa

View File

@@ -127,6 +127,7 @@ m4_define([b4_shared_declarations],
b4_percent_code_get([[requires]])[ b4_percent_code_get([[requires]])[
#include <algorithm> #include <algorithm>
#include <cstddef> // ptrdiff_t #include <cstddef> // ptrdiff_t
#include <cstring> // memcpy
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <stdexcept> #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() { ~yyGLRStackItem() {
if (isState()) { if (isState()) {
getState().~yyGLRState(); getState().~yyGLRState();