================
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -std=c++20 -Wdeprecated-declarations -I%S/Inputs -verify %s
+
+#include "std-compare.h"
+
+namespace GH147293 {
+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
+};
+
+}
+
+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);
+}
+
+}
----------------
cor3ntin wrote:
Generally, a warning is useful if the user can do something about it.
And here the "user" is usually the person using the class, not the one writing
the class.
So warning is useless here as none of the ways to fix the warnings are actually
viable.
- You could not use the defaulted function, but if that was the intent that
function could be mark deprecated
- You could write the definition instead of defaulting it, but if you don't
own the class it's not an option
Note that in general, deprecating a private field is a weird thing to do.
https://github.com/llvm/llvm-project/pull/219177
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits