<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/131108>131108</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang] Warn about unnecessary virtual specifiers
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zmodem
      </td>
    </tr>
</table>

<pre>
    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() ... ]
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8U02vqzgM_TVhYxVBgNuyYNF7q-5m1cWsTWJKZkJSxYFO59c_Bfpur96XFIkEx8fn5NjIbK6OqBPNu2hOGc5x9KH7f_Kapqz3-tF9eMdGUxDVURTreiueqzhyDLOKcIHBOLQg9u-iOAIsJsQZLSzeaBi8F_IgZCuqFBX703PzBWc7XlKN6vhKeCtAe2In5D6CXygEownQPeJo3BXQaTARFDrnI_T0_YomBz0pnJngAoY3dkJ-AHvQpCyGlG7iJ1HDcEeONMx2RY0jgfLTzVgKoPxsNdwxOMDezxHiiDHfWO92u23zFz56gsQDGWZekfo5gnGAwGYyFgMsZFyi8WHRXX_GnWjqKTDcR6NGwEDwr_N3B44WChD9bySuZC0yJxnWK7Tpbvo7GEup3uAD0H843Sz90kaHE_ENFT0d_LT1z4amMOR5DsnTr85ux-IomvcUdn7jRwyagllIwxD8BJfEzQfACJaQIzjvaH3dl9k_9sRWrzl9VZDprtJt1WJGXbmvy0OzLxqZjV07NENPe13rVrZ1fdB9WUvVNAdVNz0e6sx0spBNUZVV0ZZFI3PqpdRvJWKrh0EPUtQFTWhsbu0y5T5cM8M8U1dWZVkcMos9WV6nR0qVXBXVURu8Os_RKBZSprEKXUrf9fOVRV1Yw5FfgNFEuw7glt-c4O9XS8zOkSJmDI9PE_hGygyGAmdzsN0Y443TK8mzkOeriePc58pPQp5Tjedndwv-H1JRyPOqgIU8P0UsnfwWAAD__ztIRgc">