Skip to content

Commit

Permalink
[clang] Remove diagnostic that came with [[clang::preferred_type]] (#…
Browse files Browse the repository at this point in the history
…70632)

#69104 introduce a diagnostic that checked underlying type of an enum against type of bit-field that is annotated with `[[clang::preferred_type]]`. When I tried to introduce this annotation in #70349, it turned out to be too chatty, despite effort to avoid that.
  • Loading branch information
Endilll committed Nov 2, 2023
1 parent 43e13fd commit 98da183
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 26 deletions.
1 change: 0 additions & 1 deletion clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def BitFieldConstantConversion : DiagGroup<"bitfield-constant-conversion",
[SingleBitBitFieldConstantConversion]>;
def BitFieldEnumConversion : DiagGroup<"bitfield-enum-conversion">;
def BitFieldWidth : DiagGroup<"bitfield-width">;
def BitFieldType : DiagGroup<"bitfield-type">;
def CompoundTokenSplitByMacro : DiagGroup<"compound-token-split-by-macro">;
def CompoundTokenSplitBySpace : DiagGroup<"compound-token-split-by-space">;
def CompoundTokenSplit : DiagGroup<"compound-token-split",
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3167,9 +3167,6 @@ def err_invalid_branch_protection_spec : Error<
"invalid or misplaced branch protection specification '%0'">;
def warn_unsupported_branch_protection_spec : Warning<
"unsupported branch protection specification '%0'">, InGroup<BranchProtection>;
def warn_attribute_underlying_type_mismatch : Warning<
"underlying type %0 of enumeration %1 doesn't match bit-field type %2">,
InGroup<BitFieldType>;

def warn_unsupported_target_attribute
: Warning<"%select{unsupported|duplicate|unknown}0%select{| CPU|"
Expand Down
22 changes: 0 additions & 22 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5928,28 +5928,6 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
S.RequireCompleteType(ParmTSI->getTypeLoc().getBeginLoc(), QT,
diag::err_incomplete_type);

if (QT->isEnumeralType()) {
auto IsCorrespondingType = [&](QualType LHS, QualType RHS) {
assert(LHS != RHS);
if (LHS->isSignedIntegerType())
return LHS == S.getASTContext().getCorrespondingSignedType(RHS);
return LHS == S.getASTContext().getCorrespondingUnsignedType(RHS);
};
QualType BitfieldType =
cast<FieldDecl>(D)->getType()->getCanonicalTypeUnqualified();
QualType EnumUnderlyingType = QT->getAs<EnumType>()
->getDecl()
->getIntegerType()
->getCanonicalTypeUnqualified();
if (EnumUnderlyingType != BitfieldType &&
!IsCorrespondingType(EnumUnderlyingType, BitfieldType)) {
S.Diag(ParmTSI->getTypeLoc().getBeginLoc(),
diag::warn_attribute_underlying_type_mismatch)
<< EnumUnderlyingType << QT << BitfieldType;
return;
}
}

D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI));
}

Expand Down

0 comments on commit 98da183

Please sign in to comment.