On Wed, Sep 24, 2014 at 12:59:17PM -0700, Josh Gao wrote:
> Hi all,
> 
> This patch adds a diagnostic that warns when virtual methods that override 
> are not tagged 'override'.
> 
> commit c33643ab4f12148ed6cdc5a8a5b0be282c7b0451
> Author: Josh Gao <jmg...@gmail.com>
> Date:   Wed Sep 24 12:29:39 2014 -0700
> 
>     Add diagnostic to require virtual methods to be tagged override.
>     
>         * c-family/c.opt: Add -Wmissing-virtual-override.
>         * cp/class.c: Implement -Wmissing-virtual-override.
>         * testsuite/g++.dg/cpp0x/override5.C: New test.

Please drop the c-family/, cp/ and testsuite/ prefixes; these should
go into ChangeLogs in appropriate subdirectories.
 
> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
> index 72ac2ed..db350d7 100644
> --- a/gcc/c-family/c.opt
> +++ b/gcc/c-family/c.opt
> @@ -558,6 +558,10 @@ Wmissing-field-initializers
>  C ObjC C++ ObjC++ Var(warn_missing_field_initializers) Warning 
> EnabledBy(Wextra)
>  Warn about missing fields in struct initializers
>  
> +Wmissing-virtual-override
> +C++ ObjC++ Var(warn_missing_virtual_override) Warning
> +Warn about missing \"override\" specifier in virtual methods that override.

No dot at the end here.

>  Wsizeof-pointer-memaccess
>  C ObjC C++ ObjC++ Var(warn_sizeof_pointer_memaccess) Warning LangEnabledBy(C 
> ObjC C++ ObjC++,Wall)
>  Warn about suspicious length parameters to certain string functions if the 
> argument uses sizeof
> diff --git a/gcc/cp/class.c b/gcc/cp/class.c
> index 010ed25..f44cb82 100644
> --- a/gcc/cp/class.c
> +++ b/gcc/cp/class.c
> @@ -2773,6 +2773,8 @@ 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);

These lines are too long, please wrap them.  Also add a space before
(.

Please describe the new option in doc/invoke.texi.

        Marek

Reply via email to