Issue 147293
Summary Don't warn about deprecated fields in implicitly generated special member functions
Labels new issue
Assignees
Reporter HolyBlackCat
    This gives a warning:
```cpp
struct A
{
 [[deprecated]] int x = 42;
};

int main()
{
    A a;
    A b = a;
 a = b;
}
```
```console
<source>:1:8: warning: 'A::x' is deprecated [-Wdeprecated-declarations]
    1 | struct A
      | ^
<source>:3:24: note: declared here
    3 |     [[deprecated]] int x = 42;
      |                        ^
<source>:1:8: warning: 'A::x' is deprecated [-Wdeprecated-declarations]
    1 | struct A
      | ^
<source>:3:24: note: declared here
    3 |     [[deprecated]] int x = 42;
      |                        ^
<source>: In function 'int main()':
<source>:8:7: note: synthesized method 'constexpr A::A()' first required here
    8 |     A a;
      |       ^
```
IMO this isn't very useful. Only the manual uses of this field should warn, not the implicit ones.

GCC has the same issue, but MSVC doesn't. I've tested on Clang 20 and trunk.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to