[clang] [Clang] suppress deprecated field warnings in implicit special-member functions (PR #147400)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 8 09:05:49 PDT 2025


================
@@ -547,6 +547,15 @@ static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K,
     return;
   }
   case AR_Deprecated:
+    // Suppress -Wdeprecated-declarations in purely implicit special-member functions.
+    if (auto *MD = dyn_cast_if_present<CXXMethodDecl>(S.getCurFunctionDecl());
+        MD && MD->isImplicit() && MD->isDefaulted() &&
+        (isa<CXXConstructorDecl, CXXDestructorDecl>(MD) ||
+        MD->isCopyAssignmentOperator() ||
+        MD->isMoveAssignmentOperator())) {
+    return;
+    }
+
----------------
cor3ntin wrote:

Yes, that was a typo, sorry about that. I meant `FunctionDecl` !

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


More information about the cfe-commits mailing list