[clang] Sema: suppress deprecated field warnings in implicit special-member functions Fixes: https://github.com/llvm/llvm-project/issues/147293 (PR #147400)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 8 01:47:30 PDT 2025


================
@@ -547,6 +547,20 @@ static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K,
     return;
   }
   case AR_Deprecated:
+    // Suppress -Wdeprecated-declarations in purely implicit special-member functions.
+    if (const FunctionDecl *FD = S.getCurFunctionDecl()) {
+      // Only proceed if this is an implicit, defaulted member function:
+      if (auto *MD = dyn_cast_if_present<CXXMethodDecl>(FD);
----------------
zwuis wrote:

```cpp
if (auto *MD = dyn_cast_if_present<CXXMethodDecl>(S.getCurFunctionDecl());
    MD && ...)
```

See <https://llvm.org/docs/ProgrammersManual.html#the-isa-cast-and-dyn-cast-templates>.

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


More information about the cfe-commits mailing list