aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clang/docs/ReleaseNotes.rst1
-rw-r--r--clang/lib/Sema/SemaAvailability.cpp6
-rw-r--r--clang/test/Sema/implicit-special-member-deprecated.cpp24
3 files changed, 31 insertions, 0 deletions
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dd6b44d..e685233 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -988,6 +988,7 @@ Bug Fixes to C++ Support
non-empty initializer list. (#GH147949)
- Fixed constant evaluation of equality comparisons of constexpr-unknown references. (#GH147663)
- Diagnose binding a reference to ``*nullptr`` during constant evaluation. (#GH48665)
+- Suppress -Wdeprecated-declarations in implicitly generated functions. (#GH147293)
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp
index 8c6a173..68a698f 100644
--- a/clang/lib/Sema/SemaAvailability.cpp
+++ b/clang/lib/Sema/SemaAvailability.cpp
@@ -547,6 +547,12 @@ 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
new file mode 100644
index 0000000..8e23404
--- /dev/null
+++ b/clang/test/Sema/implicit-special-member-deprecated.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++20 -Wdeprecated-declarations -verify %s
+
+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
+
+void assignA() {
+ A a, b;
+ a = b; // copy-assign implicit → no warn
+}
+
+void useA() {
+ A a;
+ (void)a.x; // expected-warning {{is deprecated}}
+}
+
+// Explicitly-defaulted ctor – now silent
+struct B {
+ [[deprecated]] int y;
+ B() = default; // no warning under new policy
+};