summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-09-23 22:07:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-09-23 22:07:44 +0000
commitd209967a68dc11e255c9794d77340dce080a84e6 (patch)
tree127ddce4ffe1463e4a5e6ae9ab776f08c0e478dc /clang/lib/Sema
parentd93aa1060a66d4d58b72918cc5c1a9ff762e81ef (diff)
downloadbcm5719-llvm-d209967a68dc11e255c9794d77340dce080a84e6.tar.gz
bcm5719-llvm-d209967a68dc11e255c9794d77340dce080a84e6.zip
Remove warning on over-wide bit-field of boolean type; there's no risk that
someone thought all the bits would be value bits in this case. Also fix the wording of the warning -- it claimed that the width of 'bool' is 8, which is not correct; the width is 1 bit, whereas the size is 8 bits in our implementation. llvm-svn: 248435
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9195a060dbf..592f393d464 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12660,13 +12660,18 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc,
CStdConstraintViolation ? TypeWidth : TypeStorageSize;
if (FieldName)
return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
- << FieldName << (unsigned)Value.getZExtValue() << DiagWidth;
+ << FieldName << (unsigned)Value.getZExtValue()
+ << !CStdConstraintViolation << DiagWidth;
return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
- << (unsigned)Value.getZExtValue() << DiagWidth;
+ << (unsigned)Value.getZExtValue() << !CStdConstraintViolation
+ << DiagWidth;
}
- if (BitfieldIsOverwide) {
+ // Warn on types where the user might conceivably expect to get all
+ // specified bits as value bits: that's all integral types other than
+ // 'bool'.
+ if (BitfieldIsOverwide && !FieldTy->isBooleanType()) {
if (FieldName)
Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
<< FieldName << (unsigned)Value.getZExtValue()
OpenPOWER on IntegriCloud