diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 8501bc5b224..9c641ddbb65 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -12626,11 +12626,14 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc, } if (!FieldTy->isDependentType()) { - uint64_t TypeWidth = Context.getIntWidth(FieldTy); + bool UseMSBitfieldSemantics = + IsMsStruct || Context.getTargetInfo().getCXXABI().isMicrosoft(); + bool UseStorageSize = getLangOpts().CPlusPlus && UseMSBitfieldSemantics; + uint64_t TypeWidth = UseStorageSize ? Context.getTypeSize(FieldTy) + : Context.getIntWidth(FieldTy); if (Value.ugt(TypeWidth)) { - if (!getLangOpts().CPlusPlus || IsMsStruct || - Context.getTargetInfo().getCXXABI().isMicrosoft()) { - if (FieldName) + if (!getLangOpts().CPlusPlus || UseMSBitfieldSemantics) { + if (FieldName) return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width) << FieldName << (unsigned)Value.getZExtValue() << (unsigned)TypeWidth; |