build: Add warning for non-virtual destructor and fix discovered issues
Change-Id: I1d67b9b63d84d8524580e80ac06c3efef860c56a
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 1521d2a..bba2b1e 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -136,6 +136,7 @@
'-Wall',
'-Wextra',
'-Werror',
+ '-Wnon-virtual-dtor',
'-Wno-error=deprecated-declarations', # Bug #3795
'-Wno-error=maybe-uninitialized', # Bug #1615
'-Wno-unused-parameter',
@@ -150,6 +151,7 @@
'-pedantic',
'-Wall',
'-Wextra',
+ '-Wnon-virtual-dtor',
'-Wno-unused-parameter',
]
flags['LINKFLAGS'] += ['-fuse-ld=gold', '-Wl,-O1']
diff --git a/daemon/face/internal-transport.hpp b/daemon/face/internal-transport.hpp
index 6296110..67a53b3 100644
--- a/daemon/face/internal-transport.hpp
+++ b/daemon/face/internal-transport.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -37,6 +37,9 @@
class InternalTransportBase
{
public:
+ virtual
+ ~InternalTransportBase() = default;
+
/** \brief causes the transport to receive a link-layer packet
*/
virtual void
diff --git a/daemon/table/name-tree-iterator.hpp b/daemon/table/name-tree-iterator.hpp
index cb0921d..6251acd 100644
--- a/daemon/table/name-tree-iterator.hpp
+++ b/daemon/table/name-tree-iterator.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -139,6 +139,9 @@
explicit
EnumerationImpl(const NameTree& nt);
+ virtual
+ ~EnumerationImpl() = default;
+
virtual void
advance(Iterator& i) = 0;
@@ -154,7 +157,7 @@
public:
FullEnumerationImpl(const NameTree& nt, const EntrySelector& pred);
- virtual void
+ void
advance(Iterator& i) override;
private:
@@ -171,7 +174,7 @@
public:
PartialEnumerationImpl(const NameTree& nt, const EntrySubTreeSelector& pred);
- virtual void
+ void
advance(Iterator& i) override;
private:
@@ -188,7 +191,7 @@
PrefixMatchImpl(const NameTree& nt, const EntrySelector& pred);
private:
- virtual void
+ void
advance(Iterator& i) override;
private:
diff --git a/rib/readvertise/readvertise-policy.hpp b/rib/readvertise/readvertise-policy.hpp
index ebcc6c0..dce10b1 100644
--- a/rib/readvertise/readvertise-policy.hpp
+++ b/rib/readvertise/readvertise-policy.hpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -45,6 +45,9 @@
class ReadvertisePolicy : noncopyable
{
public:
+ virtual
+ ~ReadvertisePolicy() = default;
+
/** \brief decide whether to readvertise a route, and what prefix to readvertise
*/
virtual ndn::optional<ReadvertiseAction>
diff --git a/tests/tools/mock-nfd-mgmt-fixture.hpp b/tests/tools/mock-nfd-mgmt-fixture.hpp
index 4eeab41..d0498e5 100644
--- a/tests/tools/mock-nfd-mgmt-fixture.hpp
+++ b/tests/tools/mock-nfd-mgmt-fixture.hpp
@@ -26,11 +26,11 @@
#ifndef NFD_TESTS_TOOLS_MOCK_NFD_MGMT_FIXTURE_HPP
#define NFD_TESTS_TOOLS_MOCK_NFD_MGMT_FIXTURE_HPP
-#include <ndn-cxx/util/dummy-client-face.hpp>
-
#include "tests/test-common.hpp"
#include "tests/identity-management-fixture.hpp"
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
namespace nfd {
namespace tools {
namespace tests {
@@ -56,6 +56,9 @@
});
}
+ virtual
+ ~MockNfdMgmtFixture() = default;
+
protected: // ControlCommand
/** \brief check the Interest is a command with specified prefix
* \retval nullopt last Interest is not the expected command
diff --git a/tools/ndn-autoconfig/procedure.hpp b/tools/ndn-autoconfig/procedure.hpp
index 0f65b89..67e1209 100644
--- a/tools/ndn-autoconfig/procedure.hpp
+++ b/tools/ndn-autoconfig/procedure.hpp
@@ -45,6 +45,9 @@
public:
Procedure(Face& face, KeyChain& keyChain);
+ virtual
+ ~Procedure() = default;
+
void
initialize(const Options& options);