+2015-01-05 Trevor Saunders <tsaunders@mozilla.com>
+
+ PR c++/31397
+ * doc/invoke.texi: Document -Wsuggest-override.
+
2015-01-05 Radovan Obradovic <radovan.obradovic@imgtec.com>
PR rtl-optimization/64287
+2015-01-05 Trevor Saunders <tsaunders@mozilla.com>
+
+ PR c++/31397
+ * c.opt (Wsuggest-override): New option.
+
2015-01-05 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
C ObjC C++ ObjC++ Var(warn_suggest_attribute_format) Warning
Warn about functions which might be candidates for format attributes
+Wsuggest-override
+C++ ObjC++ Var(warn_override) Warning
+Suggest that the override keyword be used when the declaration of a virtual
+function overrides another.
+
Wswitch
C ObjC C++ ObjC++ Var(warn_switch) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn about enumerated switches, with no default, missing a case
+2015-01-05 Trevor Saunders <tsaunders@mozilla.com>
+
+ PR c++/31397
+ * class.c (check_for_override): Warn when a virtual function is an
+ override not marked override.
+
2015-01-05 Trevor Saunders <tsaunders@mozilla.com>
* class.c (warn_hidden): Use auto_vec<tree> instead of tree_list to
{
DECL_VINDEX (decl) = decl;
overrides_found = true;
+ if (warn_override && !DECL_OVERRIDE_P (decl)
+ && !DECL_DESTRUCTOR_P (decl))
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wsuggest_override,
+ "%q+D can be marked override", decl);
}
if (DECL_VIRTUAL_P (decl))
-Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol
-Wstrict-aliasing=n @gol -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{]} @gol
--Wsuggest-final-types @gol -Wsuggest-final-methods @gol
+-Wsuggest-final-types @gol -Wsuggest-final-methods @gol -Wsuggest-override @gol
-Wmissing-format-attribute @gol
-Wswitch -Wswitch-default -Wswitch-enum -Wswitch-bool -Wsync-nand @gol
-Wsystem-headers -Wtrampolines -Wtrigraphs -Wtype-limits -Wundef @gol
suggestions of @option{-Wsuggest-final-types} and then rebuild with new
annotations.
+@item -Wsuggest-override
+Warn about overriding virtual functions that are not marked with the override
+keyword.
+
@item -Warray-bounds
@opindex Wno-array-bounds
@opindex Warray-bounds
--- /dev/null
+// { dg-do compile }
+// { dg-options "-std=c++11 -Wsuggest-override" }
+struct A
+{
+ A();
+ virtual ~A();
+ virtual void f();
+ virtual int bar();
+ int c();
+ operator int();
+ virtual operator float();
+};
+
+struct B : A
+{
+ B();
+ virtual ~B();
+ virtual void f(); // { dg-warning "can be marked override" }
+virtual int bar() override;
+int c();
+operator int();
+virtual operator float(); // { dg-warning "can be marked override" }
+};