]> granicus.if.org Git - clang/commitdiff
Fix a bitfield regression. Reported by Anders Carlsson.
authorLauro Ramos Venancio <lauro.venancio@gmail.com>
Fri, 8 Feb 2008 19:46:46 +0000 (19:46 +0000)
committerLauro Ramos Venancio <lauro.venancio@gmail.com>
Fri, 8 Feb 2008 19:46:46 +0000 (19:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46889 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CodeGenTypes.cpp
test/CodeGen/2008-02-08-bitfield-bug.c [new file with mode: 0644]

index bed01eeb61bc11a509f8e7fc6cc37582019f7686..d293b4f081cb741408b06ff03910e3cef59b3b34 100644 (file)
@@ -573,5 +573,6 @@ void RecordOrganizer::placeBitField(const FieldDecl *FD) {
     CGT.addBitFieldInfo(FD, 0, BitFieldSize);
     Cursor = (Idx + 1) * TySize + BitFieldSize;
   }
-  addPaddingFields(Cursor);
+  if (Cursor > llvmSize)
+    addPaddingFields(Cursor);
 }
diff --git a/test/CodeGen/2008-02-08-bitfield-bug.c b/test/CodeGen/2008-02-08-bitfield-bug.c
new file mode 100644 (file)
index 0000000..1a9c266
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: clang %s -emit-llvm
+
+struct test {
+  unsigned a:1;
+  unsigned b:1;
+};
+
+struct test *t;
+