From a741c7e7cac18e400e4b32f77b0e441142b03901 Mon Sep 17 00:00:00 2001
From: Franck Vedrine <franck.vedrine@cea.fr>
Date: Tue, 3 Nov 2020 17:35:29 +0100
Subject: [PATCH] add missing operator=

---
 ACSLLogicType.cpp       |  4 ++--
 ACSLTermOrPredicate.cpp |  2 +-
 ACSLToken.h             |  4 ++++
 AnnotationComment.h     |  2 +-
 Clang_utils.h           | 15 +++++++++++++++
 RTTITable.h             |  7 +++++++
 gen_ast.ml              | 27 +++++++++++++++++++++------
 7 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/ACSLLogicType.cpp b/ACSLLogicType.cpp
index 58ad1d71..5c83a7a4 100644
--- a/ACSLLogicType.cpp
+++ b/ACSLLogicType.cpp
@@ -935,8 +935,8 @@ LogicType::readToken(Parser::State& state, Parser::Arguments& arguments) {
                 }
                 _seenSigned = true;
                 arguments.extendLocationWithToken(_loc);
-                DefineGotoCase(CTypeSuffix)
               }
+              DefineGotoCase(CTypeSuffix)
             }
             case KeywordToken::TLong: {
               if (_typeResult->tag_logic_type == LFLOAT) {
@@ -974,8 +974,8 @@ LogicType::readToken(Parser::State& state, Parser::Arguments& arguments) {
                       "unexpected 'long' type specification")
                 }
                 arguments.extendLocationWithToken(_loc);
-                DefineGotoCase(CTypeSuffix)
               }
+              DefineGotoCase(CTypeSuffix)
             }
             case KeywordToken::TShort: {
               // can only be mixed with signed, unsigned, and int
diff --git a/ACSLTermOrPredicate.cpp b/ACSLTermOrPredicate.cpp
index 2f90271c..037be800 100644
--- a/ACSLTermOrPredicate.cpp
+++ b/ACSLTermOrPredicate.cpp
@@ -6133,8 +6133,8 @@ TermOrPredicate::readToken(Parser::State& state, Parser::Arguments& arguments) {
                   arguments.extendLocationWithToken(_loc);
                   if (_doesStopTypeAmbiguity)
                     DefineTReduce;
-                  DefineGotoCase(AfterPrimary)
                 }
+                break;
               case KeywordToken::TAt:
                 if (excludeTypeAsResult()) {
                   _startLocation = arguments.newTokenLocation();
diff --git a/ACSLToken.h b/ACSLToken.h
index b0989a12..4c1d72e4 100644
--- a/ACSLToken.h
+++ b/ACSLToken.h
@@ -130,6 +130,10 @@ protected:
 public:
   AbstractToken(Type type) {}
   AbstractToken(const AbstractToken& source) : FormatParameters(source) {}
+  AbstractToken& operator=(const AbstractToken& source)
+    { FormatParameters::operator=(source);
+      return *this;
+    }
   virtual ~AbstractToken() {}
   virtual AbstractToken* clone() const { return _clone(); }
 
diff --git a/AnnotationComment.h b/AnnotationComment.h
index b81b4e78..34a381fb 100644
--- a/AnnotationComment.h
+++ b/AnnotationComment.h
@@ -158,7 +158,7 @@ public:
     { assert(0); return KUndefined; }
 
   //! checks annotation for improper use of preprocessor direcctives, returns true if errors found
-  virtual bool checkAnnotation(const std::string& text, clang::SourceLocation clangLocation, const clang::Sema* sema) const {
+  virtual bool checkAnnotation(const std::string& text, clang::SourceLocation clangLocation, const clang::Sema* sema, std::string& revised) const {
     return true;
   }
 }; 
diff --git a/Clang_utils.h b/Clang_utils.h
index 0d0c5688..89e3a8bf 100644
--- a/Clang_utils.h
+++ b/Clang_utils.h
@@ -824,6 +824,11 @@ public:
   ForwardReferenceList() : _front(NULL), _back(NULL) {}
   ForwardReferenceList(const ForwardReferenceList& source)
     : _front(source._front), _back(source._back) {}
+  ForwardReferenceList& operator=(const ForwardReferenceList& source)
+    { _front = source._front;
+      _back = source._back;
+      return *this;
+    }
   ForwardReferenceList(list& alist) : _front(&alist), _back(alist)
     { while (_back && _back->next) _back = _back->next; }
 
@@ -905,6 +910,11 @@ public:
     : ForwardReferenceList(source), _beforeBack(NULL) {}
   ForwardDoubleReferenceList(list& alist) : ForwardReferenceList(alist),
       _beforeBack(NULL) {}
+  ForwardDoubleReferenceList& operator=(const ForwardDoubleReferenceList& source)
+    { ForwardReferenceList::operator=(source);
+      _beforeBack = NULL;
+      return *this;
+    }
 
   void clear()
     { ForwardReferenceList::clear();
@@ -960,6 +970,11 @@ public:
   ForwardList() : _front(NULL), _back(NULL) {}
   ForwardList(const ForwardList& source)
     : _front(source._front), _back(source._back) {}
+  ForwardList& operator=(const ForwardList& source)
+    { _front = source._front;
+      _back = source._back;
+      return *this;
+    }
   bool isValid() const { return (!_front ? !_back : (_back && !_back->next)); }
   ForwardList& insertPlain(long value)
     { if (_back) {
diff --git a/RTTITable.h b/RTTITable.h
index 11e53d21..bb4cc49b 100644
--- a/RTTITable.h
+++ b/RTTITable.h
@@ -78,6 +78,13 @@ private:
         : _method(source._method), _inheritancePath(source._inheritancePath),
           _virtualInheritancePath(source._virtualInheritancePath),
           _parentInheritancePath(source._parentInheritancePath) {}
+      VirtualMethodInfo& operator=(const VirtualMethodInfo& source)
+        { _method = source._method;
+          _inheritancePath = source._inheritancePath;
+          _virtualInheritancePath = source._virtualInheritancePath;
+          _parentInheritancePath = source._parentInheritancePath;
+          return *this;
+        }
 
       bool isValid() const
         { return _method
diff --git a/gen_ast.ml b/gen_ast.ml
index d65039b2..4af499b2 100644
--- a/gen_ast.ml
+++ b/gen_ast.ml
@@ -703,6 +703,15 @@ let generate_c_constructor fmt ast =
   pretty_list ~pre:"@[<v 0>" ~sep:"@;@;" ~suf:"@;@;@]"
     generate_constructor fmt ast
 
+let has_free_access_content t =
+  match t with
+    | Bool | Int | Int64 -> false
+    | Location -> true
+    | String -> false
+    | Node _ -> true
+    | Option _ -> true
+    | List _ -> true
+
 let rec generate_free_call obj fmt t =
   match t with
     | Bool | Int | Int64 -> ()
@@ -728,12 +737,18 @@ let rec generate_free_call obj fmt t =
 and destruct_ptr_or_int obj fmt t =
   if not (is_base_type t) then begin
     let content fmt = Format.pp_print_string fmt "content" in
-    Format.fprintf fmt
-      "%a content = (%a)%t.container;@;%a"
-      print_c_type t
-      print_c_type t
-      obj
-      (generate_free_call content) t
+    if (has_free_access_content t)
+    then
+      Format.fprintf fmt
+        "%a content = (%a)%t.container;@;%a"
+        print_c_type t
+        print_c_type t
+        obj
+        (generate_free_call content) t
+    else
+      Format.fprintf fmt
+        "%a"
+        (generate_free_call content) t
   end
  
 
-- 
GitLab