[PATCH] D10018: C11 _Bool bitfield diagnostic

Rachel Craik via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 14:17:08 PDT 2015


rcraik added inline comments.

================
Comment at: lib/Sema/SemaDecl.cpp:12586
@@ -12585,3 +12585,3 @@
   if (!FieldTy->isDependentType()) {
     uint64_t TypeSize = Context.getTypeSize(FieldTy);
     if (Value.getZExtValue() > TypeSize) {
----------------
hubert.reinterpretcast wrote:
> rsmith wrote:
> > I think the right way to fix this is to call `getIntWidth` here instead of `getTypeSize`, and finesse our error message to clarify that we're talking about the width of the type (the number of value bits) rather than the size of the type (the number of storage bits).
> The implementation of `getIntWidth` currently makes this consideration moot at this time, but should this extend to C89 (aside from the `_Bool` extension)?
I think we have three options (the special case for _Bool bitfields being removed in each case):
  # change `getTypeSize` to `getIntWidth` and leave the rest of the checks as-is 
  # change `getTypeSize` to `getIntWidth` and update the C/MS diagnostic to either `ExtWarn` or `Warning`  (for some or all language levels)
  # leave as `getTypeSize` for lower language levels

Opinions?


http://reviews.llvm.org/D10018





More information about the cfe-commits mailing list