[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 25 17:21:19 PST 2024
================
@@ -10509,14 +10516,18 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
ED->getNumPositiveBits() == FieldWidth) {
DiagID = diag::warn_signed_bitfield_enum_conversion;
}
-
+ unsigned PreferredTypeDiagIndex = PTAttr != nullptr;
if (DiagID) {
- S.Diag(InitLoc, DiagID) << Bitfield << ED;
+ S.Diag(InitLoc, DiagID) << Bitfield << PreferredTypeDiagIndex << ED;
TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo();
SourceRange TypeRange =
TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange();
S.Diag(Bitfield->getTypeSpecStartLoc(), diag::note_change_bitfield_sign)
<< SignedEnum << TypeRange;
+ if (PTAttr) {
+ S.Diag(PTAttr->getLocation(), diag::note_bitfield_preferred_type)
+ << ED;
+ }
----------------
ojhunt wrote:
Must I :D ?
I don't like unbraced multiline blocks even if it's a single statement and so the braces are "unnecessary".
https://github.com/llvm/llvm-project/pull/116785
More information about the cfe-commits
mailing list