Test the right condition, add a comment && a test.

http://reviews.llvm.org/D10508

Files:
  lib/CodeGen/CGClass.cpp
  test/CodeGenCXX/destructor-crash.cpp

Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1293,6 +1293,10 @@
                          const CXXRecordDecl *BaseClassDecl,
                          const CXXRecordDecl *MostDerivedClassDecl)
 {
+  // Give up if the destructor is not accessible.
+  if (!BaseClassDecl->getDestructor())
+    return false;
+
   // If the destructor is trivial we don't have to check anything else.
   if (BaseClassDecl->hasTrivialDestructor())
     return true;
Index: test/CodeGenCXX/destructor-crash.cpp
===================================================================
--- test/CodeGenCXX/destructor-crash.cpp
+++ test/CodeGenCXX/destructor-crash.cpp
@@ -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 {}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1293,6 +1293,10 @@
                          const CXXRecordDecl *BaseClassDecl,
                          const CXXRecordDecl *MostDerivedClassDecl)
 {
+  // Give up if the destructor is not accessible.
+  if (!BaseClassDecl->getDestructor())
+    return false;
+
   // If the destructor is trivial we don't have to check anything else.
   if (BaseClassDecl->hasTrivialDestructor())
     return true;
Index: test/CodeGenCXX/destructor-crash.cpp
===================================================================
--- test/CodeGenCXX/destructor-crash.cpp
+++ test/CodeGenCXX/destructor-crash.cpp
@@ -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 {}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to