[cfe-commits] r126036 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/destructor.cpp

Douglas Gregor dgregor at apple.com
Sat Feb 19 11:14:36 PST 2011


Author: dgregor
Date: Sat Feb 19 13:14:36 2011
New Revision: 126036

URL: http://llvm.org/viewvc/llvm-project?rev=126036&view=rev
Log:
Teach the virtual-functions-without-virtual-destructor warning to only
warn about polymorphic classes (which have virtual functions) rather
than dynamic classes (which are polymorphic or have virtual bases).

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=126036&r1=126035&r2=126036&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Feb 19 13:14:36 2011
@@ -2767,7 +2767,7 @@
   }
 
   // Warn if the class has virtual methods but non-virtual public destructor.
-  if (Record->isDynamicClass() && !Record->isDependentType()) {
+  if (Record->isPolymorphic() && !Record->isDependentType()) {
     CXXDestructorDecl *dtor = Record->getDestructor();
     if (!dtor || (!dtor->isVirtual() && dtor->getAccess() == AS_public))
       Diag(dtor ? dtor->getLocation() : Record->getLocation(),

Modified: cfe/trunk/test/SemaCXX/destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/destructor.cpp?rev=126036&r1=126035&r2=126036&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/destructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/destructor.cpp Sat Feb 19 13:14:36 2011
@@ -172,3 +172,8 @@
 
 TS2<int> foo; // expected-note {{instantiation}}
 }
+
+namespace PR9238 {
+  class B { public: ~B(); };
+  class C : virtual B { public: ~C() { } };
+}





More information about the cfe-commits mailing list