[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-07-25 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

--- Comment #14 from Jason Merrill  ---
(In reply to Stephan Bergmann from comment #12)
> This still starts to produces spurious warnings for diamond inheritance:

Fixed, thanks.

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-07-25 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

--- Comment #13 from CVS Commits  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:4c6567b4090d9363f90b5c68e238e7d0964b6e89

commit r13-1824-g4c6567b4090d9363f90b5c68e238e7d0964b6e89
Author: Jason Merrill 
Date:   Sun Jul 24 23:26:59 2022 -0400

c++: -Woverloaded-virtual false positive [PR87729]

My attempt to shortcut unnecessary checking after finding a match was
also wrong for multiple inheritance, so let's give up on it.

PR c++/87729

gcc/cp/ChangeLog:

* class.cc (warn_hidden): Remove shortcut.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Woverloaded-virt4.C: New test.

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-07-08 Thread sbergman at redhat dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

--- Comment #12 from Stephan Bergmann  ---
(In reply to CVS Commits from comment #11)
> The master branch has been updated by Jason Merrill :
> 
> https://gcc.gnu.org/g:81bec060e31b6ef2feeb3046c6f13a207c6f698a
> 
> commit r13-1559-g81bec060e31b6ef2feeb3046c6f13a207c6f698a
> Author: Jason Merrill 
> Date:   Thu Jul 7 10:12:04 2022 -0400
> 
> c++: -Woverloaded-virtual and dtors [PR87729]

This still starts to produces spurious warnings for diamond inheritance:

> $ cat test.cc
> struct S1 { virtual void f(); };
> struct S2: S1 {};
> struct S3: S1 {};
> struct S4: S2, S3 { void f(); };

> $ g++ -Woverloaded-virtual -fsyntax-only test.cc
> test.cc:1:26: warning: ‘virtual void S1::f()’ was hidden 
> [-Woverloaded-virtual=]
> 1 | struct S1 { virtual void f(); };
>   |  ^
> test.cc:4:26: note:   by ‘virtual void S4::f()’
> 4 | struct S4: S2, S3 { void f(); };
>   |  ^

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-07-07 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

--- Comment #11 from CVS Commits  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:81bec060e31b6ef2feeb3046c6f13a207c6f698a

commit r13-1559-g81bec060e31b6ef2feeb3046c6f13a207c6f698a
Author: Jason Merrill 
Date:   Thu Jul 7 10:12:04 2022 -0400

c++: -Woverloaded-virtual and dtors [PR87729]

My earlier patch broke out of the loop over base members when we found a
match, but that caused trouble for dtors, which can have multiple for which
same_signature_p is true.  But as the function comment says, we know this
doesn't apply to [cd]tors, so skip them.

PR c++/87729

gcc/cp/ChangeLog:

* class.cc (warn_hidden): Ignore [cd]tors.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Woverloaded-virt3.C: New test.

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-07-05 Thread sbergman at redhat dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

Stephan Bergmann  changed:

   What|Removed |Added

 CC||sbergman at redhat dot com

--- Comment #10 from Stephan Bergmann  ---
(In reply to CVS Commits from comment #8)
> The master branch has been updated by Jason Merrill :
> 
> https://gcc.gnu.org/g:113844d68e94f4e9c0e946db351ba7d3d4a1335a
> 
> commit r13-1262-g113844d68e94f4e9c0e946db351ba7d3d4a1335a
> Author: Jason Merrill 
> Date:   Fri Jun 24 14:40:12 2022 -0400
> 
> c++: Include -Woverloaded-virtual in -Wall [PR87729]

This started to cause spurious -Woverloaded-virtual= warnings now (first
reported at 
"Re: [pushed] c++: Include -Woverloaded-virtual in -Wall [PR87729]"):

> $ cat test.cc
> struct S1 {};
> struct S2: S1 { virtual ~S2(); };
> struct S3 { virtual ~S3(); };
> struct S4: S2, S3 { virtual ~S4(); };

> $ g++ -Woverloaded-virtual -fsyntax-only test.cc
> test.cc:3:21: warning: ‘virtual S3::~S3()’ was hidden [-Woverloaded-virtual=]
> 3 | struct S3 { virtual ~S3(); };
>   | ^
> test.cc:4:29: note:   by ‘virtual S4::~S4()’
> 4 | struct S4: S2, S3 { virtual ~S4(); };
>   | ^
> test.cc:3:21: warning: ‘virtual S3::~S3()’ was hidden [-Woverloaded-virtual=]
> 3 | struct S3 { virtual ~S3(); };
>   | ^
> test.cc:4:29: note:   by ‘virtual S4::~S4()’
> 4 | struct S4: S2, S3 { virtual ~S4(); };
>   | ^
> test.cc:3:21: warning: ‘virtual S3::~S3()’ was hidden [-Woverloaded-virtual=]
> 3 | struct S3 { virtual ~S3(); };
>   | ^
> test.cc:4:29: note:   by ‘virtual S4::~S4()’
> 4 | struct S4: S2, S3 { virtual ~S4(); };
>   | ^

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-06-24 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

Jason Merrill  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #9 from Jason Merrill  ---
Done for GCC 13.

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-06-24 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

--- Comment #8 from CVS Commits  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:113844d68e94f4e9c0e946db351ba7d3d4a1335a

commit r13-1262-g113844d68e94f4e9c0e946db351ba7d3d4a1335a
Author: Jason Merrill 
Date:   Fri Jun 24 14:40:12 2022 -0400

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.

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-06-24 Thread dblaikie at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

David Blaikie  changed:

   What|Removed |Added

 CC||dblaikie at gmail dot com

--- Comment #7 from David Blaikie  ---
FWIW, I implemented (or at least tuned) overloaded-virtual in Clang - it
doesn't quite match GCC's behavior. (specifically it doesn't warn on two
overloads within the same class - it specifically warns on the case where a
user might've mismatched what was intended to be an override but instead became
an overload).

At least that's my recollection.

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2022-06-24 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org
   Target Milestone|--- |13.0
 CC||jason at gcc dot gnu.org

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2020-09-20 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org

--- Comment #6 from Eric Gallager  ---
(In reply to xantares09 from comment #5)
> still there with 10.1, see attached patch

Please submit your patch to the gcc-patches mailing list for review

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2020-08-07 Thread xantares09 at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

--- Comment #5 from xantares09 at hotmail dot com ---
still there with 10.1, see attached patch

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2020-08-07 Thread xantares09 at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

xantares09 at hotmail dot com changed:

   What|Removed |Added

 CC||xantares09 at hotmail dot com

--- Comment #4 from xantares09 at hotmail dot com ---
Created attachment 49021
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49021=edit
enable -Woverloaded-virtual by -Wall

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2019-01-02 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

Eric Gallager  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-01-02
 Ever confirmed|0   |1

--- Comment #3 from Eric Gallager  ---
(In reply to Daniel Fruzynski from comment #2)
> Here you are:
> 
> [code]
> class Foo
> {
> public:
> virtual void f(int);
> };
> 
> class Bar : public Foo
> {
> public:
> virtual void f(short);
> };
> [/code]

Thanks, confirmed.

$ /usr/local/bin/g++ -c -Wall 87729.cc
$ clang++ -c -Wall 87729.cc
87729.cc:10:16: warning: 'Bar::f' hides overloaded virtual function
[-Woverloaded-virtual]
  virtual void f(short);
   ^
87729.cc:4:16: note: hidden overloaded virtual function 'Foo::f' declared here:
type mismatch at 1st parameter ('int' vs 'short')
  virtual void f(int);
   ^
1 warning generated.
$

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2019-01-02 Thread bugzi...@poradnik-webmastera.com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

--- Comment #2 from Daniel Fruzynski  ---
Here you are:

[code]
class Foo
{
public:
virtual void f(int);
};

class Bar : public Foo
{
public:
virtual void f(short);
};
[/code]

[Bug c++/87729] Please include -Woverloaded-virtual in -Wall

2019-01-01 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87729

--- Comment #1 from Eric Gallager  ---
(In reply to Daniel Fruzynski from comment #0)
> clang includes -Woverloaded-virtual in -Wall. Please do same for gcc.

I was looking for a testcase to check and tried g++.dg/warn/pr61945.C but clang
doesn't warn on that with -Wall. Do you have a better testcase to show how
clang warns but gcc doesn't?