[PATCH] Fix PR19253: Do not emit global destructor warning for trivial explicitly defaulted destructors
Stephan Tolksdorf
st at quanttec.com
Thu Mar 27 12:54:26 PDT 2014
Thanks for the review!
I previously didn't consider that hasIrrelevantDestructor is used to avoid semantic checks and hence must be false if such a check would fail for an ill-formed program. I'll upload an updated patch in a moment.
================
Comment at: lib/AST/DeclCXX.cpp:944-945
@@ -940,2 +943,4 @@
SMKind |= SMF_Destructor;
- else if (D->isCopyAssignmentOperator())
+ data().HasIrrelevantDestructor =
+ D->isTrivial() && D->getAccess() == AS_public && !D->isDeleted();
+ } else if (D->isCopyAssignmentOperator())
----------------
Richard Smith wrote:
> Following the pattern elsewhere in this file, this should be:
>
> if (D->isTrivial() && D->getAccess() == AS_public && !D->isDeleted())
> data().HasIrrelevantDestructor = true;
>
> I think this is also slightly more correct: in C++98, if a base class destructor is explicitly-deleted or explicitly-defaulted but non-public (we allow this as an extension), the derived class can still have a trivial, public, non-deleted destructor, that is not irrelevant (because it calls a non-irrelevant destructor, and in particular, any odr-use of the derived class destructor is ill-formed).
I think we need the negated form here:
if (!D->isTrivial() || D->getAccess() != AS_public || D->isDeleted())
data().HasIrrelevantDestructor = false;
http://llvm-reviews.chandlerc.com/D3190
More information about the cfe-commits
mailing list