erichkeane added a comment.

LGTM, questioning whether we want to do some macro introspection in C mode (as 
the CORRECT way to use these 1 bit-bitfields is as a bool), but at least this 
gives the person the ability to disable this warning.



================
Comment at: clang/test/Sema/constant-conversion.c:27
   s.b = 0;  // no-warning
-  s.b = 1;  // expected-warning {{implicit truncation from 'int' to bit-field 
changes value from 1 to -1}}
+  s.b = 1;  // one-bit-warning {{implicit truncation from 'int' to a one-bit 
wide bit-field changes value from 1 to -1}}
   s.b = 2;  // expected-warning {{implicit truncation from 'int' to bit-field 
changes value from 2 to 0}}
----------------
Can you add a test that shows this isn't diagnosed:

`s.b = true;`?

Thanks to stdbool.h, this of course might have to be in the C++ test (or C23).  
Makes me question whether we need to do some detection to see if someone has 
written the above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132851/new/

https://reviews.llvm.org/D132851

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to