summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-12-02 07:16:50 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-12-02 07:16:50 +0000
commit6393aac45ef332a22b9eca8efc6c13cb5b84d314 (patch)
tree1f194467e56472e0ebf57557d74e67c8603f7e8e
parentdf76fe45e6fc446c398aa55d3de40a4d732bd064 (diff)
downloadbcm5719-llvm-6393aac45ef332a22b9eca8efc6c13cb5b84d314.tar.gz
bcm5719-llvm-6393aac45ef332a22b9eca8efc6c13cb5b84d314.zip
Fix another "operator delete missing" crash: make sure we don't check
isVirtual() before we've actually calculated whether the destructor is virtual. llvm-svn: 90303
-rw-r--r--clang/lib/Sema/SemaDecl.cpp8
-rw-r--r--clang/test/CodeGenCXX/virtual-inherited-destructor.cpp8
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5d62ace9070..b44d977b6a4 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3240,8 +3240,6 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD,
Diag(NewFD->getLocation(), diag::err_destructor_name);
return NewFD->setInvalidDecl();
}
-
- CheckDestructor(Destructor);
}
Record->setUserDeclaredDestructor(true);
@@ -3265,6 +3263,12 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD,
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/clang/test/CodeGenCXX/virtual-inherited-destructor.cpp b/clang/test/CodeGenCXX/virtual-inherited-destructor.cpp
new file mode 100644
index 00000000000..52b62edd294
--- /dev/null
+++ b/clang/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;
+
OpenPOWER on IntegriCloud