[Bug c++/65856] -Wsuggest-override shall not report a warning on final method

2016-10-17 Thread a.volkov at rusbitech dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65856

--- Comment #13 from Alexander Volkov  ---
There was no response, so I created a new bugreport:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

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

2016-10-17 Thread a.volkov at rusbitech dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010

Bug ID: 78010
   Summary: --Wsuggest-override reports a redundant warning on a
'final' method
   Product: gcc
   Version: 5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: a.volkov at rusbitech dot ru
  Target Milestone: ---

Hi,

gcc reports a warning on a 'final' method which is not specified as 'virtual':
struct A {
  virtual void f();
};
struct B : A {
  void f() final;
};

There is no need to suggest adding override for B::f(): without the 'virtual'
specifier 'final' means that B::f() is an overrider.

[Bug c++/65856] -Wsuggest-override shall not report a warning on final method

2016-10-13 Thread a.volkov at rusbitech dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65856

--- Comment #12 from Alexander Volkov  ---
Sorry, it should be
struct B : A {
  virtual void f() final;
};
in the first example.

[Bug c++/65856] -Wsuggest-override shall not report a warning on final method

2016-10-13 Thread a.volkov at rusbitech dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65856

Alexander Volkov  changed:

   What|Removed |Added

 CC||a.volkov at rusbitech dot ru

--- Comment #11 from Alexander Volkov  ---
Please, reopen.

Of course, it makes sense to suggest adding override in the following case:
struct A {
  virtual void f();
};
struct B : A {
  virtual void f() final override;
};

B::f() is specified as virtual, so if we remove A::f(), then B::f() will not
become a new virtual, but we'll get a compile error instead thanks to
'override' keyword.

But it is redundant in the following case:
struct A {
  virtual void f();
};
struct B : A {
  void f() final;
};

It is absolutely clear that B::f() overrides A::f(). If we remove A::f() or
change it's signature, then we'll get an error. There is no need to add
'override' here.

[Bug c++/68391] -Wsuggest-override does not work on Item 12 of Effective Modern C++

2016-10-13 Thread a.volkov at rusbitech dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68391

Alexander Volkov  changed:

   What|Removed |Added

 CC||a.volkov at rusbitech dot ru

--- Comment #1 from Alexander Volkov  ---
-Wsuggest-override should not produce warnings in this case, because none of
members of Derived override virtual functions of Base.

-Woverloaded-virtual has another meaning: "With this option, the compiler warns
when you define a function with the same name as a virtual function, but with a
type signature that does not match any declarations from the base class."