diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-08-06 05:32:55 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-08-06 05:32:55 +0000 |
commit | 82397139c47a41675ab337290f6dca7644e541d5 (patch) | |
tree | 98a1d97713191a269f08f32452d9a503d3d9041f | |
parent | 10e3dedb6f6bf999e23700f876f7e19e650ef642 (diff) |
Fix EmitNullInitializationToLValue for bitfield lvalues.
- PR2643
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54397 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 6 | ||||
-rw-r--r-- | test/CodeGen/PR2643-null-store-to-bitfield.c | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index df90ee09f5..e51a852451 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -340,10 +340,8 @@ void AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) { void AggExprEmitter::EmitNullInitializationToLValue(LValue LV, QualType T) { if (!CGF.hasAggregateLLVMType(T)) { // For non-aggregates, we can store zero - const llvm::Type *T = - cast<llvm::PointerType>(LV.getAddress()->getType())->getElementType(); - // FIXME: volatility - Builder.CreateStore(llvm::Constant::getNullValue(T), LV.getAddress()); + llvm::Value *Null = llvm::Constant::getNullValue(CGF.ConvertType(T)); + CGF.EmitStoreThroughLValue(RValue::get(Null), LV, T); } else { // Otherwise, just memset the whole thing to zero. This is legal // because in LLVM, all default initializers are guaranteed to have a diff --git a/test/CodeGen/PR2643-null-store-to-bitfield.c b/test/CodeGen/PR2643-null-store-to-bitfield.c new file mode 100644 index 0000000000..4fef84255a --- /dev/null +++ b/test/CodeGen/PR2643-null-store-to-bitfield.c @@ -0,0 +1,10 @@ +// RUN: clang -emit-llvm -o - %s +// PR2643 + +void foo() { + struct { + int a : 1; + int b : 1; + } entry = {0}; +} + |