[llvm-commits] [llvm-gcc-4.0] r46338 - /llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
Devang Patel
dpatel at apple.com
Thu Jan 24 16:43:55 PST 2008
Author: dpatel
Date: Thu Jan 24 18:43:54 2008
New Revision: 46338
URL: http://llvm.org/viewvc/llvm-project?rev=46338&view=rev
Log:
Fix 2008-01-24-StructAlignAndBitFields.c test case.
Bit-field type does not influence struct alignment.
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-types.cpp?rev=46338&r1=46337&r2=46338&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Thu Jan 24 18:43:54 2008
@@ -1529,9 +1529,14 @@
// Handle bit-fields specially.
if (DECL_BIT_FIELD_TYPE(Field)) {
- DecodeStructBitField(Field, Info);
- return true;
- }
+ // Bit-field type does not influence structure alignment.
+ // For example, struct A { char a; short b; int c:25; char d; } does not
+ // have 4 byte alignment. To enforce this rule, always use packed struct.
+ if (!Info.isPacked())
+ return false;
+ DecodeStructBitField(Field, Info);
+ return true;
+ }
Info.allFieldsAreNotBitFields();
More information about the llvm-commits
mailing list