Bug 98864 - Warning for unnecessary final keyword
Summary: Warning for unnecessary final keyword
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2021-01-28 13:14 UTC by Ulrich Drepper
Modified: 2021-01-29 00:35 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-01-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ulrich Drepper 2021-01-28 13:14:36 UTC
Compile the following code:

struct foo {
  virtual void f();
};

struct bar final : foo {
  void f() final override;
};

It is correct and should compile but the function bar::f is annotated with 'final' even though the entire class is also annotated with 'final'.  This adds nothing and might be an indication of misunderstanding or leftovers from previous versions of the code.

Perhaps a warning can be added to point out the issue.
Comment 1 Marek Polacek 2021-01-28 15:39:42 UTC
Confirmed.