[PATCH] D24289: Add warning when assigning enums to bitfields without an explicit unsigned underlying type

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 8 14:19:52 PDT 2016

aaron.ballman added a subscriber: aaron.ballman.

Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2962
@@ -2959,1 +2961,3 @@
+  "the enum %0 an unsigned underlying type">,
+  InGroup<DiagGroup<"signed-enum-bitfield">>, DefaultIgnore;
 def warn_attribute_packed_for_bitfield : Warning<
thakis wrote:
> Hm, isn't the more safe default to have it on by default? A "what you're doing isn't portable" warning seems useful, and people who don't care can easily turn it off. And if it's not off by default, it's hard for people who do care to turn it on (they'll have to know about the warning).
> Maybe it should be off-by-default but part of -Wall?
I would also vote for this being on by default rather than off by default. We usually try to avoid adding new, off-by-default warnings because they are basically undiscoverable warnings that no one enables (unless we're adding them for GCC compatibility and GCC default ignores). I would be fine if it was only enabled with -Wall.


More information about the cfe-commits mailing list