diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-05-12 15:06:05 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-05-12 15:06:05 +0000 |
commit | c8ba9614ca5469c3ae259e3ec09792f4b8969397 (patch) | |
tree | 1d01c4b7a1893e602c9c3ece37cc7b728b3e9801 | |
parent | 6b3502c5c3eba1d3da40c4c78b31f4d8cffec051 (diff) |
Don't try to take the address of a bitfield; fixes PR2310.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50966 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 9 | ||||
-rw-r--r-- | test/CodeGen/bitfield-init.c | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 508bf75383..6b68705af7 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -304,12 +304,11 @@ void AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) { // FIXME: Are initializers affected by volatile? if (E->getType()->isComplexType()) { CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false); - return; + } else if (CGF.hasAggregateLLVMType(E->getType())) { + CGF.EmitAnyExpr(E, LV.getAddress(), false); + } else { + CGF.EmitStoreThroughLValue(CGF.EmitAnyExpr(E), LV, E->getType()); } - RValue RV = CGF.EmitAnyExpr(E, LV.getAddress(), false); - if (CGF.hasAggregateLLVMType(E->getType())) - return; - CGF.EmitStoreThroughLValue(RV, LV, E->getType()); } void AggExprEmitter::EmitNullInitializationToLValue(LValue LV, QualType T) { diff --git a/test/CodeGen/bitfield-init.c b/test/CodeGen/bitfield-init.c index 6e89e1185a..c5f6139800 100644 --- a/test/CodeGen/bitfield-init.c +++ b/test/CodeGen/bitfield-init.c @@ -2,3 +2,11 @@ typedef struct { unsigned int i: 1; } c; const c d = { 1 }; +// PR2310 +struct Token { + unsigned n : 31; +}; +void sqlite3CodeSubselect(){ + struct Token one = { 1 }; +} + |