Hi!
On Wed, Sep 24, 2014 at 02:08:01PM -0700, Josh Gao wrote:
> commit b4d15d3cf660708dca088361801ebd56e018f986
> Author: Josh Gao <[email protected]>
> Date: Wed Sep 24 14:01:16 2014 -0700
>
> Add diagnostic to require virtual methods to be tagged override.
>
> gcc/Changelog
> * doc/invoke.texi (-Wmissing-virtual-override): Add.
>
> gcc/c-family
> * c.opt: Add -Wmissing-virtual-override.
A nit: this should probably be
* c.opt (Wmissing-virtual-override): New option.
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 666f1a6..9392e7b 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,6 @@
> +2014-09-24 Josh Gao <[email protected]>
> + * doc/invoke.texi (-Wmissing-virtual-override): Add.
> +
> 2014-09-24 Jan Hubicka <[email protected]>
>
> * ipa-utils.h (polymorphic_call_context): Add
> diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
> index 2278e77..56ec987 100644
> --- a/gcc/c-family/ChangeLog
> +++ b/gcc/c-family/ChangeLog
> @@ -1,3 +1,6 @@
> +2014-09-24 Josh Gao <[email protected]>
> + * c.opt: Add -Wmissing-virtual-override.
> +
> 2014-09-24 Marek Polacek <[email protected]>
>
> PR c/61405
Please don't include ChangeLogs in the patch itself, it makes the
patch hard to apply. Instead, just include the ChangeLog entry before
the patch, as you did above.
> --- a/gcc/cp/class.c
> +++ b/gcc/cp/class.c
> @@ -2773,6 +2773,9 @@ check_for_override (tree decl, tree ctype)
> error ("%q+#D marked %<final%>, but is not virtual", decl);
> if (DECL_OVERRIDE_P (decl) && !overrides_found)
> error ("%q+#D marked %<override%>, but does not override", decl);
> + if (!DECL_OVERRIDE_P (decl) && overrides_found && !DECL_DESTRUCTOR_P
> (decl))
> + warning (OPT_Wmissing_virtual_override,
> + "%q+#D overrides, but is not marked %<override%>", decl);
Shouldn't this new if be better 'else if'?
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,6 @@
> +2014-09-24 Josh Gao <[email protected]>
> + * g++.dg/cpp0x/override5.C: New test.
This test seems to be missing in the patch; forgot to git add?
Thanks,
Marek