[clang] [Clang] handle [[warn_unused]] attribute for unused private fields (PR #120734)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 26 15:06:14 PST 2024
================
@@ -3307,6 +3307,29 @@ void Sema::CheckShadowInheritedFields(const SourceLocation &Loc,
}
}
+template <typename AttrType>
+inline static bool HasAttribute(const QualType &T) {
----------------
a-tarasyuk wrote:
@erichkeane The main concern in the issue description is that the private field `s` isn't triggering the unused warning. I couldn't find the relevant specification for it, so the question remains: should the private field `s` trigger an unused warning, or should the issue be closed?
```cpp
class [[gnu::warn_unused]] S
{
public:
S();
};
void f()
{
int i = 0; // unused variable 'i'
S s; // unused variable 's'
}
class C
{
private:
const int i = 0; // private field 'i' is not used
const S s; // ok
};
```
https://github.com/llvm/llvm-project/pull/120734
More information about the cfe-commits
mailing list