Author: Vlad Serebrennikov Date: 2023-11-02T16:17:17+04:00 New Revision: 98da18344eed96cabfd2214131185686b1983412
URL: https://github.com/llvm/llvm-project/commit/98da18344eed96cabfd2214131185686b1983412 DIFF: https://github.com/llvm/llvm-project/commit/98da18344eed96cabfd2214131185686b1983412.diff LOG: [clang] Remove diagnostic that came with `[[clang::preferred_type]]` (#70632) https://github.com/llvm/llvm-project/pull/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 https://github.com/llvm/llvm-project/pull/70349, it turned out to be too chatty, despite effort to avoid that. Added: Modified: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaDeclAttr.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 9a8f3f03b39d165..4c4820d17b7184c 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -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", diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 224c0df7f1fb71f..474afc2fb99c1f0 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -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|" diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 5e43f66d8be8d76..842a01a88cd3c6d 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -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)); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits