[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2019-05-10 Thread barry.revzin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

--- Comment #13 from Barry Revzin  ---
Thanks Marek!

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2019-05-10 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Marek Polacek  changed:

   What|Removed |Added

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

--- Comment #12 from Marek Polacek  ---
Fixed for 9.2 and 10.

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2019-05-10 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

--- Comment #11 from Marek Polacek  ---
Author: mpolacek
Date: Fri May 10 14:57:22 2019
New Revision: 271066

URL: https://gcc.gnu.org/viewcvs?rev=271066=gcc=rev
Log:
PR c++/78010 - bogus -Wsuggest-override warning on final function.
* class.c (check_for_override): Don't warn for final functions.

* g++.dg/warn/Wsuggest-override-2.C: New test.

Added:
branches/gcc-9-branch/gcc/testsuite/g++.dg/warn/Wsuggest-override-2.C
Modified:
branches/gcc-9-branch/gcc/cp/ChangeLog
branches/gcc-9-branch/gcc/cp/class.c

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2019-05-10 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

--- Comment #10 from Marek Polacek  ---
Author: mpolacek
Date: Fri May 10 14:53:30 2019
New Revision: 271065

URL: https://gcc.gnu.org/viewcvs?rev=271065=gcc=rev
Log:
PR c++/78010 - bogus -Wsuggest-override warning on final function.
* class.c (check_for_override): Don't warn for final functions.

* g++.dg/warn/Wsuggest-override-2.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/warn/Wsuggest-override-2.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/class.c
trunk/gcc/testsuite/ChangeLog

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2019-05-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||mpolacek at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

--- Comment #9 from Marek Polacek  ---
This can't be too hard to fix; let me try.

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2019-05-06 Thread barry.revzin at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Barry Revzin  changed:

   What|Removed |Added

 CC||barry.revzin at gmail dot com

--- Comment #8 from Barry Revzin  ---
Still happens on 9.1.

This is actually worse than just a spurious warning. I want to use
-Wsuggest-override, but we weren't carefully marking overrides in our code base
for a long time... so I used clang-tidy's modernize-use-override check
(https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-override.html) to
do all the marking so that I can enable this warning. Yay tooling.

clang-tidy, though, in addition to adding missing "override"s also removes
redundant "virtual"s and replaces a redundant "override final" with just
"final" (as Jonathan mentions in comment #2, the Core Guidelines also agree
this is redundant). Which means that manual intervention is still necessary to
get gcc to not warn.

This is a really good warning (would've fixed at least two bugs that I've ran
into in production), and we even have existing tooling to remove what would
have been all the false positives via clang-tidy... just need gcc to not flag
the remaining false positive cases.

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2018-01-10 Thread albert.astals.cid at kdab dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Albert Astals Cid  changed:

   What|Removed |Added

 CC||albert.astals.cid at kdab dot 
com

--- Comment #7 from Albert Astals Cid  ---
*** Bug 83767 has been marked as a duplicate of this bug. ***

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2017-10-05 Thread lloyd at randombit dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Jack Lloyd  changed:

   What|Removed |Added

 CC||lloyd at randombit dot net

--- Comment #6 from Jack Lloyd  ---
Still occurs with GCC 7.2.0

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2017-04-25 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

--- Comment #5 from Jonathan Wakely  ---
(In reply to Arnaud Desitter from comment #3)
> Interesting reference. Note that "virtual + final" can be useful even if the
> core guidelines discourage its use.
> 
> struct A {
>   virtual void f() final;
> };
> struct B : A {
>// "void f()" cannot be defined
> };

What would be the point in that?

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2017-04-25 Thread ol.rakhimov at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

--- Comment #4 from ol.rakhimov at gmail dot com ---
(In reply to Arnaud Desitter from comment #3)
> Interesting reference. Note that "virtual + final" can be useful even if the
> core guidelines discourage its use.
> 
> struct A {
>   virtual void f() final;
> };
> struct B : A {
>// "void f()" cannot be defined
> };

I've seen this in Bjarne's C++11 FAQ/INFO pages,
but why would you do that? It's weird and uncommon.
Virtual implies functionality to be overridden.
If no override is permitted,
just use good-old plain member function.

struct A {
  void f();
};

struct B : A {
  void f();  // Comiler may warn about the hiding of A::f
};

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2017-04-25 Thread arnaud02 at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

--- Comment #3 from Arnaud Desitter  ---
Interesting reference. Note that "virtual + final" can be useful even if the
core guidelines discourage its use.

struct A {
  virtual void f() final;
};
struct B : A {
   // "void f()" cannot be defined
};

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2017-04-25 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

--- Comment #2 from Jonathan Wakely  ---
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-override
says that virtual functions should use exactly one of virtual, override or
final. Which agrees with the suggestion to not warn about functions that
already specify final.

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2017-04-25 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-04-25
 Ever confirmed|0   |1

[Bug c++/78010] --Wsuggest-override reports a redundant warning on a 'final' method

2017-04-25 Thread arnaud02 at users dot sourceforge.net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Arnaud Desitter  changed:

   What|Removed |Added

 CC||arnaud02 at users dot 
sourceforge.
   ||net

--- Comment #1 from Arnaud Desitter  ---
Considering:
struct A {
  virtual void f();
};
struct B : A {
  void f() override final;
};

"clang-tidy -checks=-*,modernize-use-override" removes "override" but gcc's
"-Wsuggest-override" requires it. So implementing the suggestion would make the
two tools compatible.