@@ -18307,16 +18307,22 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc,
1830718307 if (Value.isSigned() && Value.isNegative()) {
1830818308 if (FieldName)
1830918309 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
18310- << FieldName << toString(Value, 10);
18310+ << FieldName
18311+ << toString(Value, 10, Value.isSigned(),
18312+ /*formatAsCLiteral=*/false, /*UpperCase=*/true,
18313+ /*InsertSeparators=*/true);
1831118314 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
18312- << toString(Value, 10);
18315+ << toString(Value, 10, Value.isSigned(), /*formatAsCLiteral=*/false,
18316+ /*UpperCase=*/true, /*InsertSeparators=*/true);
1831318317 }
1831418318
1831518319 // The size of the bit-field must not exceed our maximum permitted object
1831618320 // size.
1831718321 if (Value.getActiveBits() > ConstantArrayType::getMaxSizeBits(Context)) {
1831818322 return Diag(FieldLoc, diag::err_bitfield_too_wide)
18319- << !FieldName << FieldName << toString(Value, 10);
18323+ << !FieldName << FieldName
18324+ << toString(Value, 10, Value.isSigned(), /*formatAsCLiteral=*/false,
18325+ /*UpperCase=*/true, /*InsertSeparators=*/true);
1832018326 }
1832118327
1832218328 if (!FieldTy->isDependentType()) {
@@ -18335,17 +18341,26 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc,
1833518341 unsigned DiagWidth =
1833618342 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
1833718343 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
18338- << (bool)FieldName << FieldName << toString(Value, 10)
18344+ << (bool)FieldName << FieldName
18345+ << toString(Value, 10, Value.isSigned(),
18346+ /*formatAsCLiteral=*/false, /*UpperCase=*/true,
18347+ /*InsertSeparators=*/true)
1833918348 << !CStdConstraintViolation << DiagWidth;
1834018349 }
1834118350
1834218351 // Warn on types where the user might conceivably expect to get all
1834318352 // specified bits as value bits: that's all integral types other than
1834418353 // 'bool'.
1834518354 if (BitfieldIsOverwide && !FieldTy->isBooleanType() && FieldName) {
18355+ llvm::APInt TypeWidthAP(sizeof(TypeWidth) * 8, TypeWidth,
18356+ /*IsSigned=*/false);
1834618357 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
18347- << FieldName << toString(Value, 10)
18348- << (unsigned)TypeWidth;
18358+ << FieldName
18359+ << toString(Value, 10, Value.isSigned(), /*formatAsCLiteral=*/false,
18360+ /*UpperCase=*/true, /*InsertSeparators=*/true)
18361+ << toString(TypeWidthAP, 10, /*Signed=*/false,
18362+ /*formatAsCLiteral=*/false, /*UpperCase=*/true,
18363+ /*InsertSeparators=*/true);
1834918364 }
1835018365 }
1835118366
0 commit comments