Issue 131108
Summary [clang] Warn about unnecessary virtual specifiers
Labels clang:diagnostics
Assignees
Reporter zmodem
    Consider:

```
struct S final {
  virtual void foo();
};
```

`S::foo()` doesn't override anything and it cannot be overridden because S is final, so declaring it virtual is wasteful and the compiler could warn about that.

---

Maybe not as useful but in a similar vein, Clang could warn about members which are known never to be overridden because the class is local to the file, for example:

```
namespace {
struct S {
  virtual void foo() { ... }
};
}

[... no classes derived from S, or at least none that override S::foo() ... ]
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to