mirror of
https://github.com/LibreOffice/core.git
synced 2025-08-15 09:28:00 +00:00
loplugin:unusedmember: Work around more cases not marking an enum as referenced
...similar to the "For some reason..." workaround already present in VisitElaboratedTypeLoc. (Thanks to mst for finding this.) Change-Id: Ic682e8290efa64093d3c4a831dfb4d23091b6056 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124559 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@ -13,15 +13,35 @@ namespace
|
||||
{
|
||||
struct S
|
||||
{
|
||||
enum E
|
||||
enum E1
|
||||
{
|
||||
E1,
|
||||
E2
|
||||
E11,
|
||||
E12
|
||||
};
|
||||
E e;
|
||||
E1 e1;
|
||||
enum E2
|
||||
{
|
||||
E21,
|
||||
E22
|
||||
};
|
||||
E2 e2; // expected-error {{unused class member [loplugin:unusedmember]}}
|
||||
enum E3
|
||||
{
|
||||
E31,
|
||||
E32
|
||||
} e3;
|
||||
enum E4
|
||||
{
|
||||
E41,
|
||||
E42
|
||||
} e4; // expected-error {{unused class member [loplugin:unusedmember]}}
|
||||
};
|
||||
}
|
||||
void f(S s) { (void)s.e; }
|
||||
void f(S s)
|
||||
{
|
||||
(void)s.e1;
|
||||
(void)s.e3;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ElaboratedEnum
|
||||
|
@ -94,6 +94,21 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
bool VisitDeclaratorDecl(DeclaratorDecl const* decl)
|
||||
{
|
||||
// For declarations like
|
||||
//
|
||||
// enum E { ... } e;
|
||||
//
|
||||
// it may be that the declaration of E is not marked as referenced even though the
|
||||
// declaration of e clearly references it:
|
||||
if (auto const t = decl->getType()->getAs<EnumType>())
|
||||
{
|
||||
deferred_.erase(t->getDecl());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VisitCXXRecordDecl(CXXRecordDecl const* decl) //TODO: non-CXX RecordDecl?
|
||||
{
|
||||
if (ignoreLocation(decl))
|
||||
|
Reference in New Issue
Block a user