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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Friedman 2012-01-13 03:58:31 +00:00
parent 9ec0ef31c3
commit 89e6e85f1a
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;