[clang] [clang] Remove diagnostic that came with `[[clang::preferred_type]]` (PR #70632)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 30 01:46:09 PDT 2023


================
@@ -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)) {
----------------
Endilll wrote:

> I think we should keep the diagnostics, but only emit it when the type of the enum has a sizeof that is greater than the type of the bitfields.

We can do that, but it's going to miss so much that I'm not sure it's worth our time at all.

https://github.com/llvm/llvm-project/pull/70632


More information about the cfe-commits mailing list