Issue |
160244
|
Summary |
`-Wunused-private-field` not reported for `[[gnu::warn_unused]]` annotated type when empty constructors are present
|
Labels |
clang:diagnostics,
false-negative
|
Assignees |
|
Reporter |
firewave
|
```cpp
class [[gnu::warn_unused]] S1 {
public:
S1() {}
};
class [[gnu::warn_unused]] S2 {
public:
S2() = default;
};
class [[gnu::warn_unused]] S3 {
public:
S3();
};
class [[gnu::warn_unused]] S4 {
};
class C {
public:
C() {}
private:
const S1 s1; // no warning
const S2 s2; // warning
const S3 s3; // no warning
const S4 s4; // warning
};
```
```
<source>:25:14: warning: private field 's2' is not used [-Wunused-private-field]
25 | const S2 s2; // warning
| ^
<source>:27:14: warning: private field 's4' is not used [-Wunused-private-field]
27 | const S4 s4; // warning
| ^
```
https://godbolt.org/z/rjcEMzn96
If you change the `C` constructor to `= default` all are reported regardless of the other constructor.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs