[PATCH] D14980: PR18513: make gcc compatible layout for bit-fields with explicit aligned attribute

Dmitry Polukhin via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 03:41:05 PST 2015


DmitryPolukhin added a comment.

I added more testcases and they all pass identically on GCC and clang with my patch. Please let me know if you think, that some cases are not covered or doesn't work with my patch. Perhaps we can reduce number of test-cases because some of them almost duplicates but for now I added them all.

As for MS compatibility mode, I think we shouldn't worry about them because MS does't support __attrbute__(aligned) and #pragma pack seems to have no influence on bit-filed layout as far as I tested. If you think that __attrbute__(aligned) should work in MS compatibility mode and use GCC semantic, please let me know, I'll update my patch accordingly.


================
Comment at: lib/AST/RecordLayoutBuilder.cpp:1606
@@ -1605,1 +1605,3 @@
+    } else if (ExplicitFieldAlign)
+      FieldOffset = llvm::RoundUpToAlignment(FieldOffset, ExplicitFieldAlign);
 
----------------
rsmith wrote:
> You should round up to `FieldAlign` here.
Unfortunately, I cannot use FieldAlign here because FieldAlign = max(ExplicitFieldAlign, alignof(field_type)). But GCC allows to specify alignment less than normal type alignment for bit-field, see 'struct g2' case in my testcase (it will fail if I round up to FieldAlign here).


http://reviews.llvm.org/D14980





More information about the cfe-commits mailing list