[cfe-commits] r94754 - in /cfe/trunk: lib/CodeGen/CGRecordLayoutBuilder.cpp test/CodeGen/union.c
Anders Carlsson
andersca at mac.com
Thu Jan 28 10:22:03 PST 2010
Author: andersca
Date: Thu Jan 28 12:22:03 2010
New Revision: 94754
URL: http://llvm.org/viewvc/llvm-project?rev=94754&view=rev
Log:
Fix an incorrect union layout assert. Fixes PR6164.
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/test/CodeGen/union.c
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=94754&r1=94753&r2=94754&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Thu Jan 28 12:22:03 2010
@@ -162,6 +162,8 @@
uint64_t Size = 0;
unsigned Align = 0;
+ bool HasOnlyZeroSizedBitFields = true;
+
unsigned FieldNo = 0;
for (RecordDecl::field_iterator Field = D->field_begin(),
FieldEnd = D->field_end(); Field != FieldEnd; ++Field, ++FieldNo) {
@@ -181,6 +183,8 @@
} else
Types.addFieldInfo(*Field, 0);
+ HasOnlyZeroSizedBitFields = false;
+
const llvm::Type *FieldTy =
Types.ConvertTypeForMemRecursive(Field->getType());
unsigned FieldAlign = Types.getTargetData().getABITypeAlignment(FieldTy);
@@ -207,7 +211,8 @@
}
}
if (!Align) {
- assert((D->field_begin() == D->field_end()) && "LayoutUnion - Align 0");
+ assert(HasOnlyZeroSizedBitFields &&
+ "0-align record did not have all zero-sized bit-fields!");
Align = 1;
}
Modified: cfe/trunk/test/CodeGen/union.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/union.c?rev=94754&r1=94753&r2=94754&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/union.c (original)
+++ cfe/trunk/test/CodeGen/union.c Thu Jan 28 12:22:03 2010
@@ -39,3 +39,6 @@
union RR {_Bool a : 1;} RRU;
int RRF(void) {return RRU.a;}
+// PR6164
+typedef union T0 { unsigned int : 0; } T0;
+T0 t0;
More information about the cfe-commits
mailing list