[cfe-commits] r90303 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/CodeGenCXX/virtual-inherited-destructor.cpp

Eli Friedman eli.friedman at gmail.com
Tue Dec 1 23:16:50 PST 2009


Author: efriedma
Date: Wed Dec  2 01:16:50 2009
New Revision: 90303

URL: http://llvm.org/viewvc/llvm-project?rev=90303&view=rev
Log:
Fix another "operator delete missing" crash: make sure we don't check
isVirtual() before we've actually calculated whether the destructor is
virtual.


Added:
    cfe/trunk/test/CodeGenCXX/virtual-inherited-destructor.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=90303&r1=90302&r2=90303&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Dec  2 01:16:50 2009
@@ -3240,8 +3240,6 @@
           Diag(NewFD->getLocation(), diag::err_destructor_name);
           return NewFD->setInvalidDecl();
         }
-      
-        CheckDestructor(Destructor);
       }
 
       Record->setUserDeclaredDestructor(true);
@@ -3265,6 +3263,12 @@
         AddOverriddenMethods(Method->getParent(), Method);
     }
 
+    // Additional checks for the destructor; make sure we do this after we
+    // figure out whether the destructor is virtual.
+    if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(NewFD))
+      if (!Destructor->getParent()->isDependentType())
+        CheckDestructor(Destructor);
+
     // Extra checking for C++ overloaded operators (C++ [over.oper]).
     if (NewFD->isOverloadedOperator() &&
         CheckOverloadedOperatorDeclaration(NewFD))

Added: cfe/trunk/test/CodeGenCXX/virtual-inherited-destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-inherited-destructor.cpp?rev=90303&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/virtual-inherited-destructor.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/virtual-inherited-destructor.cpp Wed Dec  2 01:16:50 2009
@@ -0,0 +1,8 @@
+// RUN: clang-cc %s -emit-llvm-only
+
+struct A { virtual ~A(); };
+struct B : A {
+  ~B() { }
+};
+B x;
+





More information about the cfe-commits mailing list