https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/219177

>From c45387ba8260b59ddd725313b13f4366cc4a6509 Mon Sep 17 00:00:00 2001
From: Younan Zhang <[email protected]>
Date: Thu, 27 Aug 2026 19:03:24 +0800
Subject: [PATCH 1/4] [Clang] Only omit deprecation warnings for implicit
 special members

31db0f0a7ae isn't very correct because synthesized deduction guides are
also marked 'implicit', and it's supposed to apply to only non-user-defined
special members.

This patch corrects that behavior.
---
 clang/docs/ReleaseNotes.md                         |  3 +++
 clang/lib/Sema/SemaAvailability.cpp                | 10 ++++------
 .../Sema/implicit-special-member-deprecated.cpp    | 14 ++++++++++++++
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 8cc8eb5f80066..796f6d7498ac3 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -533,6 +533,9 @@ features cannot lower the translation-unit ABI level;
 
 - Fixed an assertion during template argument deduction where a function 
parameter pack is referenced by other types in the function type. (#GH28877), 
(#GH213760)
 
+- Fixed a regression where deprecation warnings were omitted for synthesized
+  deduction guide. (#GH160543)
+
 - Fixed an assertion when a redeclaration of a function template or an 
out-of-line
   definition of a member of a class template added a default argument to a
   parameter that follows a parameter pack (e.g.
diff --git a/clang/lib/Sema/SemaAvailability.cpp 
b/clang/lib/Sema/SemaAvailability.cpp
index 28a4b760dbd4d..d4bb53cf0cf6e 100644
--- a/clang/lib/Sema/SemaAvailability.cpp
+++ b/clang/lib/Sema/SemaAvailability.cpp
@@ -212,6 +212,10 @@ static bool ShouldDiagnoseAvailabilityInContext(
     } else if (K == AR_Deprecated) {
       if (C->isDeprecated())
         return true;
+      // Don't emit deprecated warnings when defining special member functions.
+      if (const auto *FD = dyn_cast<FunctionDecl>(C);
+          FD && FD->isDefaulted() && FD->isImplicit())
+        return true;
     } else if (K == AR_Unavailable) {
       // It is perfectly fine to refer to an 'unavailable' Objective-C method
       // when it is referenced from within the @implementation itself. In this
@@ -548,12 +552,6 @@ static void DoEmitAvailabilityWarning(Sema &S, 
AvailabilityResult K,
     return;
   }
   case AR_Deprecated:
-    // Suppress -Wdeprecated-declarations in implicit
-    // functions.
-    if (const auto *FD = 
dyn_cast_or_null<FunctionDecl>(S.getCurFunctionDecl());
-        FD && FD->isImplicit())
-      return;
-
     if (ObjCPropertyAccess)
       diag = diag::warn_property_method_deprecated;
     else if (S.currentEvaluationContext().IsCaseExpr)
diff --git a/clang/test/Sema/implicit-special-member-deprecated.cpp 
b/clang/test/Sema/implicit-special-member-deprecated.cpp
index 8e23404552f53..ffc3df314b014 100644
--- a/clang/test/Sema/implicit-special-member-deprecated.cpp
+++ b/clang/test/Sema/implicit-special-member-deprecated.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++20 -Wdeprecated-declarations -verify %s
 
+namespace GH147293 {
 struct A {
   [[deprecated("use something else")]] int x = 42; // expected-note {{marked 
deprecated here}}
 };
@@ -22,3 +23,16 @@ struct B {
   [[deprecated]] int y;
   B() = default;                   // no warning under new policy
 };
+
+}
+
+namespace GH160543 {
+
+template<class F>
+struct [[deprecated]] X { X(F);}; // expected-warning {{is deprecated}} 
expected-note {{deprecated here}}
+
+void f() {
+  X x{0}; // expected-note {{while substituting}}
+}
+
+}

>From 2dc308ac5cdfea39bdde57511a1a0aa350ca0d1a Mon Sep 17 00:00:00 2001
From: Younan Zhang <[email protected]>
Date: Fri, 28 Aug 2026 20:26:16 +0800
Subject: [PATCH 2/4] prefer isDefault()

---
 clang/lib/Sema/SemaAvailability.cpp           |  3 +--
 .../implicit-special-member-deprecated.cpp    | 21 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 3 deletions(-)
 rename clang/test/{Sema => SemaCXX}/implicit-special-member-deprecated.cpp 
(68%)

diff --git a/clang/lib/Sema/SemaAvailability.cpp 
b/clang/lib/Sema/SemaAvailability.cpp
index d4bb53cf0cf6e..636168d13d5b8 100644
--- a/clang/lib/Sema/SemaAvailability.cpp
+++ b/clang/lib/Sema/SemaAvailability.cpp
@@ -213,8 +213,7 @@ static bool ShouldDiagnoseAvailabilityInContext(
       if (C->isDeprecated())
         return true;
       // Don't emit deprecated warnings when defining special member functions.
-      if (const auto *FD = dyn_cast<FunctionDecl>(C);
-          FD && FD->isDefaulted() && FD->isImplicit())
+      if (const auto *FD = dyn_cast<FunctionDecl>(C); FD && FD->isDefaulted())
         return true;
     } else if (K == AR_Unavailable) {
       // It is perfectly fine to refer to an 'unavailable' Objective-C method
diff --git a/clang/test/Sema/implicit-special-member-deprecated.cpp 
b/clang/test/SemaCXX/implicit-special-member-deprecated.cpp
similarity index 68%
rename from clang/test/Sema/implicit-special-member-deprecated.cpp
rename to clang/test/SemaCXX/implicit-special-member-deprecated.cpp
index ffc3df314b014..d793293ea77d5 100644
--- a/clang/test/Sema/implicit-special-member-deprecated.cpp
+++ b/clang/test/SemaCXX/implicit-special-member-deprecated.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -std=c++20 -Wdeprecated-declarations -verify %s
+// RUN: %clang_cc1 -std=c++20 -Wdeprecated-declarations -I%S/Inputs -verify %s
+
+#include "std-compare.h"
 
 namespace GH147293 {
 struct A {
@@ -26,6 +28,22 @@ struct B {
 
 }
 
+namespace GH147293_regression {
+
+struct A {
+  [[deprecated("use something else")]] int x = 42;
+
+  auto operator<=>(const A&) const = default;
+};
+
+void foo() {
+  A x, y;
+  // FIXME: We want the deprecation warnings because operator<=> uses A.x!
+  (void)(x == y);
+}
+
+}
+
 namespace GH160543 {
 
 template<class F>
@@ -36,3 +54,4 @@ void f() {
 }
 
 }
+

>From ef7248e4d0a5b4d6f17f7889a4425502f1f9e95d Mon Sep 17 00:00:00 2001
From: Younan Zhang <[email protected]>
Date: Fri, 28 Aug 2026 20:27:46 +0800
Subject: [PATCH 3/4] Replace LLM preferred right arrows with ASCII arrows

I didn't use any, it was there
---
 clang/test/SemaCXX/implicit-special-member-deprecated.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/test/SemaCXX/implicit-special-member-deprecated.cpp 
b/clang/test/SemaCXX/implicit-special-member-deprecated.cpp
index d793293ea77d5..8fcc42df226d0 100644
--- a/clang/test/SemaCXX/implicit-special-member-deprecated.cpp
+++ b/clang/test/SemaCXX/implicit-special-member-deprecated.cpp
@@ -7,12 +7,12 @@ struct A {
   [[deprecated("use something else")]] int x = 42; // expected-note {{marked 
deprecated here}}
 };
 
-A makeDefaultA() { return {}; }    // ctor is implicit → no warn
-A copyA(const A &a) { return a; }  // copy-ctor implicit → no warn
+A makeDefaultA() { return {}; }    // ctor is implicit -> no warn
+A copyA(const A &a) { return a; }  // copy-ctor implicit -> no warn
 
 void assignA() {
   A a, b;
-  a = b;                           // copy-assign implicit → no warn
+  a = b;                           // copy-assign implicit -> no warn
 }
 
 void useA() {

>From c03fb0092229329ef41fe4ccc9ec3f04e20eacde Mon Sep 17 00:00:00 2001
From: Younan Zhang <[email protected]>
Date: Tue, 1 Sep 2026 15:40:53 +0800
Subject: [PATCH 4/4] Add tests

---
 .../SemaCXX/implicit-special-member-deprecated.cpp     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/clang/test/SemaCXX/implicit-special-member-deprecated.cpp 
b/clang/test/SemaCXX/implicit-special-member-deprecated.cpp
index 8fcc42df226d0..60d235ce625ac 100644
--- a/clang/test/SemaCXX/implicit-special-member-deprecated.cpp
+++ b/clang/test/SemaCXX/implicit-special-member-deprecated.cpp
@@ -32,14 +32,20 @@ namespace GH147293_regression {
 
 struct A {
   [[deprecated("use something else")]] int x = 42;
-
   auto operator<=>(const A&) const = default;
 };
 
+struct B : A {
+  bool operator==(const B&) const = default;
+};
+
 void foo() {
   A x, y;
-  // FIXME: We want the deprecation warnings because operator<=> uses A.x!
   (void)(x == y);
+  (void)(x < y);
+
+  B bx, by;
+  (void)(bx != by);
 }
 
 }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to