diff options
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 8 | ||||
| -rw-r--r-- | clang/test/CodeGen/init.c | 7 |
2 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 6ea21ec47aa..d620d3b953a 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -857,10 +857,12 @@ void AggExprEmitter::EmitNullInitializationToLValue(LValue lv) { llvm::Value *null = llvm::Constant::getNullValue(CGF.ConvertType(type)); // Note that the following is not equivalent to // EmitStoreThroughBitfieldLValue for ARC types. - if (lv.isBitField()) + if (lv.isBitField()) { CGF.EmitStoreThroughBitfieldLValue(RValue::get(null), lv); - assert(lv.isSimple()); - CGF.EmitStoreOfScalar(null, lv, /* isInitialization */ true); + } else { + assert(lv.isSimple()); + CGF.EmitStoreOfScalar(null, lv, /* isInitialization */ true); + } } else { // There's a potential optimization opportunity in combining // memsets; that would be easy for arrays, but relatively diff --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c index 599b4f23dbd..426233d8dfd 100644 --- a/clang/test/CodeGen/init.c +++ b/clang/test/CodeGen/init.c @@ -123,3 +123,10 @@ struct test12 { struct test12 (*p)(void); } test12g; + +void test13(int x) { + struct X { int a; int b : 10; int c; }; + struct X y = {.c = x}; + // CHECK: @test13 + // CHECK: and i32 {{.*}}, -1024 +} |

