llvm-project/clang/test/Sema/implicit-special-member-deprecated.cpp
Shashi Shankar 31db0f0a7a
[Clang] Suppress deprecated field warnings in implicit functions definitions (#147400)
Do not warn on deprecated member used in an implicit definition (such as a defaulted special member function).

Co-authored-by: Corentin Jabot <corentinjabot@gmail.com>

Fixes #147293
2025-07-24 08:48:27 +02:00

25 lines
661 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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
};