llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)

<details>
<summary>Changes</summary>

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.

Fixes #<!-- -->160543

---
Full diff: https://github.com/llvm/llvm-project/pull/219177.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.md (+3) 
- (modified) clang/lib/Sema/SemaAvailability.cpp (+4-6) 
- (modified) clang/test/Sema/implicit-special-member-deprecated.cpp (+14) 


``````````diff
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}}
+}
+
+}

``````````

</details>


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

Reply via email to