From 20104048be328324112cc40c4b9df8145182e375 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 18 Sep 2011 12:11:43 +0000 Subject: PR10304: Do not call destructors for data members from union destructors. Prior to C++11, this has no effect since any such destructors must be trivial, and in C++11 such destructors must not be called. llvm-svn: 139997 --- clang/lib/CodeGen/CGClass.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang/lib/CodeGen/CGClass.cpp') diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 71cb13e9df3..615a4daa869 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -980,6 +980,10 @@ void CodeGenFunction::EnterDtorCleanups(const CXXDestructorDecl *DD, const CXXRecordDecl *ClassDecl = DD->getParent(); + // Unions have no bases and do not call field destructors. + if (ClassDecl->isUnion()) + return; + // The complete-destructor phase just destructs all the virtual bases. if (DtorType == Dtor_Complete) { -- cgit v1.2.3