title: How to be warned when overriding a virtual method with wrong visibility
body: <p>When overriding a virtual method, I noticed that when I make a mistake in the visibility (protected method overridden as a public method), I'm not warned by the compiler.</p>
  
  <p>It is valid C++, but usually it is a mistake.</p>
  
  <p>For example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class Base
  {
  protected:
    virtual void ProtectedMethod(void)
    {
      std::cout &lt;&lt; "Base::ProtectedMethod" &lt;&lt; std::endl;
    }
  };
  
  class Derived : public Base
  {
  public:
    virtual void ProtectedMethod(void)
    {
      std::cout &lt;&lt; "Derived::ProtectedMethod" &lt;&lt; std::endl;
    }
  };
  
  int main(int, char* [])
  {
    Derived d;
    d.ProtectedMethod();
  }
  </code></pre>
  
  <p>I tried compiling with gcc and clang, with -Wall -Wextra, with no luck.
  I ran CppCheck on this code, still no luck.</p>
  
  <p>What tool can help me detect this ?
  I need to fix the whole sources of a library I'm working on.</p>