[cfe-commits] r54397 - in /cfe/trunk: lib/CodeGen/CGExprAgg.cpp test/CodeGen/PR2643-null-store-to-bitfield.c
Daniel Dunbar
daniel at zuster.org
Tue Aug 5 22:32:57 PDT 2008
Author: ddunbar
Date: Wed Aug 6 00:32:55 2008
New Revision: 54397
URL: http://llvm.org/viewvc/llvm-project?rev=54397&view=rev
Log:
Fix EmitNullInitializationToLValue for bitfield lvalues.
- PR2643
Added:
cfe/trunk/test/CodeGen/PR2643-null-store-to-bitfield.c
Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=54397&r1=54396&r2=54397&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Wed Aug 6 00:32:55 2008
@@ -340,10 +340,8 @@
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
Added: cfe/trunk/test/CodeGen/PR2643-null-store-to-bitfield.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/PR2643-null-store-to-bitfield.c?rev=54397&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/PR2643-null-store-to-bitfield.c (added)
+++ cfe/trunk/test/CodeGen/PR2643-null-store-to-bitfield.c Wed Aug 6 00:32:55 2008
@@ -0,0 +1,10 @@
+// RUN: clang -emit-llvm -o - %s
+// PR2643
+
+void foo() {
+ struct {
+ int a : 1;
+ int b : 1;
+ } entry = {0};
+}
+
More information about the cfe-commits
mailing list