bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

glr2.cc: example: address Clang warnings


From: Akim Demaille
Subject: glr2.cc: example: address Clang warnings
Date: Sat, 19 Dec 2020 16:47:49 +0100

commit d6fbeb27987612d249e1c687b71af4d48fac25ec
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Sat Dec 19 07:26:35 2020 +0100

    glr2.cc: example: address Clang warnings
    
        ast.hh:24:7: error: 'Node' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit 
[-Werror,-Wweak-vtables]
        class Node
              ^
        ast.hh:57:7: error: 'Nterm' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit 
[-Werror,-Wweak-vtables]
        class Nterm : public Node
              ^
        ast.hh:102:7: error: 'Term' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit 
[-Werror,-Wweak-vtables]
        class Term : public Node
              ^
    
    * examples/c++/glr/ast.hh: Define the destructors out of the class
    definition.
    This does not change anything, it is still in the header, but that
    does pacify clang.

diff --git a/examples/c++/glr/ast.hh b/examples/c++/glr/ast.hh
index 20fab2c5..b352efc9 100644
--- a/examples/c++/glr/ast.hh
+++ b/examples/c++/glr/ast.hh
@@ -11,8 +11,7 @@ public:
     : parents_ (0)
   {}
 
-  virtual ~Node ()
-  {}
+  virtual ~Node ();
 
   void free ()
   {
@@ -30,6 +29,9 @@ protected:
   int parents_;
 };
 
+Node::~Node ()
+{}
+
 
 static std::ostream&
 operator<< (std::ostream& o, const Node &node)
@@ -55,12 +57,7 @@ public:
       child2->parents_ += 1;
   }
 
-  ~Nterm ()
-  {
-    for (int i = 0; i < 3; ++i)
-      if (children_[i])
-        children_[i]->free ();
-  }
+  ~Nterm ();
 
   std::ostream& print (std::ostream& o) const
   {
@@ -82,12 +79,21 @@ private:
   Node *children_[3];
 };
 
+Nterm::~Nterm ()
+{
+  for (int i = 0; i < 3; ++i)
+    if (children_[i])
+      children_[i]->free ();
+}
+
+
 class Term : public Node
 {
 public:
   Term (const std::string &text)
     : text_ (text)
   {}
+  ~Term();
 
   std::ostream& print (std::ostream& o) const
   {
@@ -98,3 +104,7 @@ public:
 private:
   std::string text_;
 };
+
+Term::~Term ()
+{
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]