[PATCH] D132851: Further update -Wbitfield-constant-conversion for 1-bit bitfield
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 29 07:24:52 PDT 2022
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
More information about the cfe-commits
mailing list