c++: Include -Woverloaded-virtual in -Wall [PR87729]
commit113844d68e94f4e9c0e946db351ba7d3d4a1335a
authorJason Merrill <jason@redhat.com>
Fri, 24 Jun 2022 18:40:12 +0000 (24 14:40 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 24 Jun 2022 22:23:48 +0000 (24 18:23 -0400)
tree4700337540406594bea63da9bf9543c45207dd64
parent75fa80bb5654d1f8b21310118f41705b74168039
c++: Include -Woverloaded-virtual in -Wall [PR87729]

This seems like a good warning to have in -Wall, as requested.  But as
pointed out in PR20423, some users want a warning only when a derived
function doesn't override any base function.  So let's put that lesser
version in -Wall (and -Woverloaded-virtual=1) while leaving the semantics
for the existing option the same.

PR c++/87729
PR c++/20423

gcc/c-family/ChangeLog:

* c.opt (Woverloaded-virtual): Add levels, include in -Wall.

gcc/ChangeLog:

* doc/invoke.texi: Document changes.

gcc/cp/ChangeLog:

* class.cc (warn_hidden): Handle -Woverloaded-virtual=1.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Woverloaded-virt1.C: New test.
* g++.dg/warn/Woverloaded-virt2.C: New test.
gcc/c-family/c.opt
gcc/cp/class.cc
gcc/doc/invoke.texi
gcc/testsuite/g++.dg/warn/Woverloaded-virt1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Woverloaded-virt2.C [new file with mode: 0644]