]> granicus.if.org Git - clang/commitdiff
Fix crash with constant initialization of bit-fields in unions.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 7 May 2009 23:42:42 +0000 (23:42 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 7 May 2009 23:42:42 +0000 (23:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71194 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprConstant.cpp
test/CodeGen/bitfield-init.c

index e618dab33ebeae655bde49c489aa6c21d1677e83..1639ac0939a93fd5cfce947ca8f57e6b0509f25c 100644 (file)
@@ -275,7 +275,7 @@ public:
 
     if (curField->isBitField()) {
       // Create a dummy struct for bit-field insertion
-      unsigned NumElts = CGM.getTargetData().getTypePaddedSize(Ty) / 8;
+      unsigned NumElts = CGM.getTargetData().getTypePaddedSize(Ty);
       llvm::Constant* NV = llvm::Constant::getNullValue(llvm::Type::Int8Ty);
       std::vector<llvm::Constant*> Elts(NumElts, NV);
 
index f0cc0b15680a26cccff2d101daa2892f8f0f3b46..7459614a1254aefe1516d7496eeccc3fa78fe243 100644 (file)
@@ -10,3 +10,5 @@ void sqlite3CodeSubselect(){
   struct Token one = { 1 };
 }
 
+typedef union T0 { char field0 : 2; } T0;
+T0 T0_values = { 0 };