summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-07-17 21:07:48 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-07-17 21:07:48 +0000
commit1f32c759dc3f0674032843ba66f82dffc99ab102 (patch)
tree046342cb47fa96a591ef24567d391c2e24e89eb5 /clang/lib/CodeGen/CGExprConstant.cpp
parentfd7102037d37c5a7c087aad35a3a5858301ffbe8 (diff)
downloadbcm5719-llvm-1f32c759dc3f0674032843ba66f82dffc99ab102.tar.gz
bcm5719-llvm-1f32c759dc3f0674032843ba66f82dffc99ab102.zip
Fix for codegen crash on multibit bool bitfield initialization
<rdar://problem/6078606> llvm-svn: 53737
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index fe11a5fb0ac..813bcfb8554 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -145,6 +145,13 @@ public:
while (offset < (fieldOffset & -8))
offset += CGM.getTypes().getTargetData().getTypeStoreSizeInBits(Elts[i++]->getType());
+ // Promote the size of V if necessary
+ // FIXME: This should never occur, but currently it can because
+ // initializer constants are cast to bool, and because clang is
+ // not enforcing bitfield width limits.
+ if (bitFieldInfo.Size > V.getBitWidth())
+ V.zext(bitFieldInfo.Size);
+
// Insert the bits into the struct
// FIXME: This algorthm is only correct on X86!
// FIXME: THis algorthm assumes bit-fields only have byte-size elements!
OpenPOWER on IntegriCloud