From 6d26dc23493b0a4f3ff348880eb2b8a88f378141 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 4 Oct 2018 17:57:56 +0200
Subject: [PATCH] Remove implicitly-defined copy/move constructors/assignments
 in several classes

---
 src/DataTree.hh          |  5 +++++
 src/ExprNode.hh          |  5 +++++
 src/ParsingDriver.hh     | 10 ++++++++++
 src/Statement.hh         |  7 +++++++
 src/macro/MacroDriver.hh | 11 +++++++++++
 5 files changed, 38 insertions(+)

diff --git a/src/DataTree.hh b/src/DataTree.hh
index fffb57fc..cea53af2 100644
--- a/src/DataTree.hh
+++ b/src/DataTree.hh
@@ -123,6 +123,11 @@ public:
   virtual
   ~DataTree();
 
+  DataTree(const DataTree &) = delete;
+  DataTree(DataTree &&) = delete;
+  DataTree & operator=(const DataTree &) = delete;
+  DataTree & operator=(DataTree &&) = delete;
+
   //! Some predefined constants
   expr_t Zero, One, Two, MinusOne, NaN, Infinity, MinusInfinity, Pi;
 
diff --git a/src/ExprNode.hh b/src/ExprNode.hh
index 207bb1a9..ce91ad12 100644
--- a/src/ExprNode.hh
+++ b/src/ExprNode.hh
@@ -210,6 +210,11 @@ class ExprNode
       virtual
       ~ExprNode();
 
+      ExprNode(const ExprNode &) = delete;
+      ExprNode(ExprNode &&) = delete;
+      ExprNode & operator=(const ExprNode &) = delete;
+      ExprNode & operator=(ExprNode &&) = delete;
+
       //! Initializes data member non_null_derivatives
       virtual void prepareForDerivation() = 0;
 
diff --git a/src/ParsingDriver.hh b/src/ParsingDriver.hh
index 985c3e8d..597f41e4 100644
--- a/src/ParsingDriver.hh
+++ b/src/ParsingDriver.hh
@@ -60,6 +60,11 @@ class DynareFlex : public DynareFlexLexer
 public:
   DynareFlex(istream *in = nullptr, ostream *out = nullptr);
 
+  DynareFlex(const DynareFlex &) = delete;
+  DynareFlex(DynareFlex &&) = delete;
+  DynareFlex & operator=(const DynareFlex &) = delete;
+  DynareFlex & operator=(DynareFlex &&) = delete;
+
   //! The main lexing function
   Dynare::parser::token_type lex(Dynare::parser::semantic_type *yylval,
                                  Dynare::parser::location_type *yylloc,
@@ -266,6 +271,11 @@ public:
   ParsingDriver(WarningConsolidation &warnings_arg, bool nostrict_arg) :
     warnings{warnings_arg}, nostrict{nostrict_arg} { };
 
+  ParsingDriver(const ParsingDriver &) = delete;
+  ParsingDriver(ParsingDriver &&) = delete;
+  ParsingDriver & operator=(const ParsingDriver &) = delete;
+  ParsingDriver & operator=(ParsingDriver &&) = delete;
+
   //! Starts parsing, and constructs the MOD file representation
   unique_ptr<ModFile> parse(istream &in, bool debug);
 
diff --git a/src/Statement.hh b/src/Statement.hh
index 543baa8f..a410c7d8 100644
--- a/src/Statement.hh
+++ b/src/Statement.hh
@@ -132,8 +132,15 @@ public:
 class Statement
 {
 public:
+  Statement() = default;
   virtual
   ~Statement();
+
+  Statement(const Statement &) = delete;
+  Statement(Statement &&) = delete;
+  Statement & operator=(const Statement &) = delete;
+  Statement & operator=(Statement &&) = delete;
+
   //! Do some internal check, and fill the ModFileStructure class
   /*! Don't forget to update ComputingTasks.hh, Shocks.hh and
     NumericalInitialization.hh if you modify the signature of this
diff --git a/src/macro/MacroDriver.hh b/src/macro/MacroDriver.hh
index 097fad31..1d1e9d28 100644
--- a/src/macro/MacroDriver.hh
+++ b/src/macro/MacroDriver.hh
@@ -175,6 +175,11 @@ private:
 public:
   MacroFlex(istream *in, ostream *out, bool no_line_macro_arg, vector<string> path_arg);
 
+  MacroFlex(const MacroFlex &) = delete;
+  MacroFlex(MacroFlex &&) = delete;
+  MacroFlex & operator=(const MacroFlex &) = delete;
+  MacroFlex & operator=(MacroFlex &&) = delete;
+
   //! The main lexing function
   Macro::parser::token_type lex(Macro::parser::semantic_type *yylval,
                                 Macro::parser::location_type *yylloc,
@@ -203,6 +208,12 @@ private:
 
   stack<tuple<vector<string>, shared_ptr<ArrayMV>, int>> comprehension_stack;
 public:
+  MacroDriver() = default;
+  MacroDriver(const MacroDriver &) = delete;
+  MacroDriver(MacroDriver &&) = delete;
+  MacroDriver & operator=(const MacroDriver &) = delete;
+  MacroDriver & operator=(MacroDriver &&) = delete;
+
   //! Exception thrown when value of an unknown variable is requested
   class UnknownVariable
   {
-- 
GitLab