[PATCH] Warn when a virtual function tries to override a non-virtual one
Lubos Lunak
l.lunak at centrum.cz
Mon Apr 7 00:29:09 PDT 2014
On Friday 04 of April 2014, Nico Weber wrote:
> 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).
Ok, I guess this needs a re-think given the reality. Let's scratch this for
now.
> 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
--
Lubos Lunak
More information about the cfe-commits
mailing list