A base subobject type doesn't make sense for unions; don't try to compute it. Based on patch by Yin Ma. Fixes PR11751.

llvm-svn: 148093
This commit is contained in:
Eli Friedman
2012-01-13 03:58:31 +00:00
parent dd8fbf572e
commit 09d272d025
2 changed files with 4 additions and 7 deletions

View File

@@ -997,7 +997,7 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D,
// If we're in C++, compute the base subobject type.
llvm::StructType *BaseTy = 0;
if (isa<CXXRecordDecl>(D)) {
if (isa<CXXRecordDecl>(D) && !D->isUnion()) {
BaseTy = Builder.BaseSubobjectType;
if (!BaseTy) BaseTy = Ty;
}

View File

@@ -1,10 +1,7 @@
// RUN: %clang_cc1 -emit-llvm -o - %s
union sigval { };
union sigval Test1;
union sigval sigev_value;
int main()
{
return sizeof(sigev_value);
}
union NonPODUnion { ~NonPODUnion(); };
union NonPODUnion Test2;