diff options
-rw-r--r-- | lib/VMCore/Constants.cpp | 4 | ||||
-rw-r--r-- | test/Feature/unions.ll | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index c9c9857..bd08880 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -59,6 +59,7 @@ Constant *Constant::getNullValue(const Type *Ty) { case Type::PointerTyID: return ConstantPointerNull::get(cast<PointerType>(Ty)); case Type::StructTyID: + case Type::UnionTyID: case Type::ArrayTyID: case Type::VectorTyID: return ConstantAggregateZero::get(Ty); @@ -944,7 +945,8 @@ bool ConstantFP::isValueValidForType(const Type *Ty, const APFloat& Val) { // Factory Function Implementation ConstantAggregateZero* ConstantAggregateZero::get(const Type* Ty) { - assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) && + assert((Ty->isStructTy() || Ty->isUnionTy() + || Ty->isArrayTy() || Ty->isVectorTy()) && "Cannot create an aggregate zero of non-aggregate type!"); LLVMContextImpl *pImpl = Ty->getContext().pImpl; diff --git a/test/Feature/unions.ll b/test/Feature/unions.ll index 9d6c36b..3cf8c3c 100644 --- a/test/Feature/unions.ll +++ b/test/Feature/unions.ll @@ -6,7 +6,9 @@ @union1 = constant union { i32, i8 } { i32 4 } @union2 = constant union { i32, i8 } insertvalue(union { i32, i8 } undef, i32 4, 0) +@union3 = common global %union.anon zeroinitializer, align 8 define void @"Unions" () { ret void } + |