diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-07-17 21:07:48 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-07-17 21:07:48 +0000 |
commit | 1f3846e3013a3b6679aeaa2e4c61de37a5c320ee (patch) | |
tree | bfa465677713ded04f2daca11c09a8c281c59402 /lib/CodeGen/CGExprConstant.cpp | |
parent | f59bf48ee79ed218e6dcaf1b82fa730efd0e9999 (diff) |
Fix for codegen crash on multibit bool bitfield initialization
<rdar://problem/6078606>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index fe11a5fb0a..813bcfb855 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/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! |