diff options
author | Rachel Craik <rcraik@ca.ibm.com> | 2015-09-14 21:27:36 +0000 |
---|---|---|
committer | Rachel Craik <rcraik@ca.ibm.com> | 2015-09-14 21:27:36 +0000 |
commit | 022bdc7d7361f48a359194e630e8b16f1d134cfe (patch) | |
tree | c5fb8cc07ba6e991599a0a92d16763d95f673d83 /clang/lib/Sema/SemaDecl.cpp | |
parent | bace032eb81aa9bf2bad513a693291243d03c6a7 (diff) | |
download | bcm5719-llvm-022bdc7d7361f48a359194e630e8b16f1d134cfe.tar.gz bcm5719-llvm-022bdc7d7361f48a359194e630e8b16f1d134cfe.zip |
C11 _Bool bitfield diagnostic
Summary: Implement DR262 (for C). This patch will mainly affect bitfields of type _Bool
Reviewers: fraggamuffin, rsmith
Subscribers: hubert.reinterpretcast, cfe-commits
Differential Revision: http://reviews.llvm.org/D10018
llvm-svn: 247618
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c55c07efb77..43aa2d73fc6 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -12625,26 +12625,26 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc, } if (!FieldTy->isDependentType()) { - uint64_t TypeSize = Context.getTypeSize(FieldTy); - if (Value.getZExtValue() > TypeSize) { + uint64_t TypeWidth = Context.getIntWidth(FieldTy); + if (Value.ugt(TypeWidth)) { if (!getLangOpts().CPlusPlus || IsMsStruct || Context.getTargetInfo().getCXXABI().isMicrosoft()) { if (FieldName) - return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_size) + return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width) << FieldName << (unsigned)Value.getZExtValue() - << (unsigned)TypeSize; + << (unsigned)TypeWidth; - return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_size) - << (unsigned)Value.getZExtValue() << (unsigned)TypeSize; + return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width) + << (unsigned)Value.getZExtValue() << (unsigned)TypeWidth; } if (FieldName) - Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_size) + Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width) << FieldName << (unsigned)Value.getZExtValue() - << (unsigned)TypeSize; + << (unsigned)TypeWidth; else - Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_size) - << (unsigned)Value.getZExtValue() << (unsigned)TypeSize; + Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_width) + << (unsigned)Value.getZExtValue() << (unsigned)TypeWidth; } } |