[cfe-commits] r124585 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/destructor.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Jan 31 09:10:26 PST 2011
Author: akirtzidis
Date: Mon Jan 31 11:10:25 2011
New Revision: 124585
URL: http://llvm.org/viewvc/llvm-project?rev=124585&view=rev
Log:
Only warn for -Wnon-virtual-dtor for public destructors. Thanks to Benjamin Kramer for the hint!
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/destructor.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=124585&r1=124584&r2=124585&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jan 31 11:10:25 2011
@@ -2770,10 +2770,10 @@
}
}
- // Warn if the class has virtual methods but non-virtual destructor.
+ // Warn if the class has virtual methods but non-virtual public destructor.
if (Record->isDynamicClass()) {
CXXDestructorDecl *dtor = Record->getDestructor();
- if (!(dtor && dtor->isVirtual()))
+ if (!dtor || (!dtor->isVirtual() && dtor->getAccess() == AS_public))
Diag(dtor ? dtor->getLocation() : Record->getLocation(),
diag::warn_non_virtual_dtor) << Context.getRecordType(Record);
}
Modified: cfe/trunk/test/SemaCXX/destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/destructor.cpp?rev=124585&r1=124584&r2=124585&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/destructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/destructor.cpp Mon Jan 31 11:10:25 2011
@@ -147,4 +147,16 @@
struct S5 : public B {
virtual void m();
};
+
+struct S6 {
+ virtual void m();
+private:
+ ~S6();
+};
+
+struct S7 {
+ virtual void m();
+protected:
+ ~S7();
+};
}
More information about the cfe-commits
mailing list