Fix another "operator delete missing" crash: make sure we don't check
isVirtual() before we've actually calculated whether the destructor is
virtual.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90303 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5d62ace..b44d977 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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))
diff --git a/test/CodeGenCXX/virtual-inherited-destructor.cpp b/test/CodeGenCXX/virtual-inherited-destructor.cpp
new file mode 100644
index 0000000..52b62ed
--- /dev/null
+++ b/test/CodeGenCXX/virtual-inherited-destructor.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-cc %s -emit-llvm-only
+
+struct A { virtual ~A(); };
+struct B : A {
+  ~B() { }
+};
+B x;
+