mirror of https://github.com/microsoft/clang.git
[Codegen] Don't crash if destructor is not accessible.
Testcase provided, in the PR, by Christian Shelton and reduced by David Majnemer. PR: 23584 Differential Revision: http://reviews.llvm.org/D10508 Reviewed by: rnk git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240242 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
14ff9b05ed
commit
bcdd41a1b9
|
@ -1297,6 +1297,10 @@ HasTrivialDestructorBody(ASTContext &Context,
|
|||
if (BaseClassDecl->hasTrivialDestructor())
|
||||
return true;
|
||||
|
||||
// Give up if the destructor is not accessible.
|
||||
if (!BaseClassDecl->getDestructor())
|
||||
return false;
|
||||
|
||||
if (!BaseClassDecl->getDestructor()->hasTrivialBody())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// RUN: %clang_cc1 %s -emit-llvm -std=c++11 -o %t
|
||||
|
||||
struct A {
|
||||
~A();
|
||||
};
|
||||
|
||||
struct B {
|
||||
A a;
|
||||
};
|
||||
|
||||
struct C {
|
||||
union {
|
||||
B b;
|
||||
};
|
||||
|
||||
~C() noexcept;
|
||||
};
|
||||
|
||||
C::~C() noexcept {}
|
Loading…
Reference in New Issue