[clang] Add an off-by-default warning to complain about MSVC bitfield padding (PR #117428)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 26 11:29:22 PST 2024


================
@@ -631,6 +631,7 @@ def Packed : DiagGroup<"packed", [PackedNonPod]>;
 def PaddedBitField : DiagGroup<"padded-bitfield">;
 def Padded : DiagGroup<"padded", [PaddedBitField]>;
 def UnalignedAccess : DiagGroup<"unaligned-access">;
+def MSBitfieldCompatibility : DiagGroup<"ms-bitfield-packing-compatibility">;
----------------
rnk wrote:

Bike shedding: Should we drop "packing"? Note that this covers compatibility with GCC `-mms-bitfields` and structs carrying `__attribute__((ms_struct))`, so naming parallel to `-mms-bitfields` seems good.

I think you could make this warning much more discoverable if you add documentation for it in DiagnosticDocs.td, which will be rendered to https://clang.llvm.org/docs/DiagnosticsReference.html , which is highly searchable.

https://github.com/llvm/llvm-project/pull/117428


More information about the cfe-commits mailing list