]> granicus.if.org Git - clang/commit
[clang] Warning for non-final classes with final destructors
authorDavid Bolvansky <david.bolvansky@gmail.com>
Sat, 31 Aug 2019 18:31:19 +0000 (18:31 +0000)
committerDavid Bolvansky <david.bolvansky@gmail.com>
Sat, 31 Aug 2019 18:31:19 +0000 (18:31 +0000)
commitf95996952066927cc0ff327eebaf72a865b9696a
treefda3cd49d317c9a2befbc6de6686131e2ef06c97
parent0420ce03d1d21b8622ef6a56f431689ac12bc58e
[clang] Warning for non-final classes with final destructors

Marking a class' destructor final prevents the class from being inherited from. However, it is a subtle and awkward way to express that at best, and unintended at worst. It may also generate worse code (in other compilers) than marking the class itself final. For these reasons, this revision adds a warning for nonfinal classes with final destructors, with a note to suggest marking the class final to silence the warning.

See https://reviews.llvm.org/D66621 for more background.

Patch by logan-5 (Logan Smith)

Differential Revision: https://reviews.llvm.org/D66711

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@370594 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/MicrosoftExtensions.cpp
test/SemaCXX/warn-final-dtor-non-final-class.cpp [new file with mode: 0644]