[PATCH] Warn when a virtual function tries to override a non-virtual one

Nico Weber thakis at chromium.org
Fri Apr 4 11:13:00 PDT 2014


Did you evaluate this on some large codebase for true and false positives?
The current behavior of -Woverloaded-virtual was carefully chosen to be
less noisy than gcc's version of the warning (clang's version is low enough
on noise to be useful, gcc's isn't).


On Fri, Apr 4, 2014 at 10:54 AM, Lubos Lunak <l.lunak at centrum.cz> wrote:

>
>  Testcase:
>
> struct B5 {
>     void func();
> };
> struct S5 : public B5 {
>     virtual void func();
> };
>
>  Here most likely S5::func() was meant to override B5::func() but doesn't
> because of missing 'virtual' in the base class. The attached patch warns
> about this case. I added the warning to -Woverloaded-virtual, because
> although technically it is not an overloaded virtual, it is exactly the
> same
> kind of a developer mistake, but if somebody insists I can update the patch
> to make it -Woverridden-non-virtual (which I think is a misnomer too :) )
> or
> whatever you name it.
>
> --
>  Lubos Lunak
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140404/1484e8b3/attachment.html>


More information about the cfe-commits mailing list