Skip to content

Commit 98da183

Browse files
authored
[clang] Remove diagnostic that came with [[clang::preferred_type]] (#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.
1 parent 43e13fd commit 98da183

File tree

3 files changed

+0
-26
lines changed

3 files changed

+0
-26
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def BitFieldConstantConversion : DiagGroup<"bitfield-constant-conversion",
5454
[SingleBitBitFieldConstantConversion]>;
5555
def BitFieldEnumConversion : DiagGroup<"bitfield-enum-conversion">;
5656
def BitFieldWidth : DiagGroup<"bitfield-width">;
57-
def BitFieldType : DiagGroup<"bitfield-type">;
5857
def CompoundTokenSplitByMacro : DiagGroup<"compound-token-split-by-macro">;
5958
def CompoundTokenSplitBySpace : DiagGroup<"compound-token-split-by-space">;
6059
def CompoundTokenSplit : DiagGroup<"compound-token-split",

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,9 +3167,6 @@ def err_invalid_branch_protection_spec : Error<
31673167
"invalid or misplaced branch protection specification '%0'">;
31683168
def warn_unsupported_branch_protection_spec : Warning<
31693169
"unsupported branch protection specification '%0'">, InGroup<BranchProtection>;
3170-
def warn_attribute_underlying_type_mismatch : Warning<
3171-
"underlying type %0 of enumeration %1 doesn't match bit-field type %2">,
3172-
InGroup<BitFieldType>;
31733170

31743171
def warn_unsupported_target_attribute
31753172
: Warning<"%select{unsupported|duplicate|unknown}0%select{| CPU|"

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5928,28 +5928,6 @@ static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
59285928
S.RequireCompleteType(ParmTSI->getTypeLoc().getBeginLoc(), QT,
59295929
diag::err_incomplete_type);
59305930

5931-
if (QT->isEnumeralType()) {
5932-
auto IsCorrespondingType = [&](QualType LHS, QualType RHS) {
5933-
assert(LHS != RHS);
5934-
if (LHS->isSignedIntegerType())
5935-
return LHS == S.getASTContext().getCorrespondingSignedType(RHS);
5936-
return LHS == S.getASTContext().getCorrespondingUnsignedType(RHS);
5937-
};
5938-
QualType BitfieldType =
5939-
cast<FieldDecl>(D)->getType()->getCanonicalTypeUnqualified();
5940-
QualType EnumUnderlyingType = QT->getAs<EnumType>()
5941-
->getDecl()
5942-
->getIntegerType()
5943-
->getCanonicalTypeUnqualified();
5944-
if (EnumUnderlyingType != BitfieldType &&
5945-
!IsCorrespondingType(EnumUnderlyingType, BitfieldType)) {
5946-
S.Diag(ParmTSI->getTypeLoc().getBeginLoc(),
5947-
diag::warn_attribute_underlying_type_mismatch)
5948-
<< EnumUnderlyingType << QT << BitfieldType;
5949-
return;
5950-
}
5951-
}
5952-
59535931
D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI));
59545932
}
59555933

0 commit comments

Comments
 (0)