Fixed #2279 ((style) struct of union member is never used)
This commit is contained in:
parent
ac60a41a7e
commit
b25e6ff24c
|
@ -2121,6 +2121,11 @@ void CheckOther::checkStructMemberUsage()
|
|||
{
|
||||
// Declaring struct variable..
|
||||
std::string varname;
|
||||
|
||||
// declaring a POD variable?
|
||||
if (!tok->next()->isStandardType())
|
||||
continue;
|
||||
|
||||
if (Token::Match(tok->next(), "%type% %var% [;[]"))
|
||||
varname = tok->strAt(2);
|
||||
else if (Token::Match(tok->next(), "%type% %type% %var% [;[]"))
|
||||
|
|
|
@ -46,6 +46,7 @@ private:
|
|||
TEST_CASE(structmember8);
|
||||
TEST_CASE(structmember9); // #2017 - struct is inherited
|
||||
TEST_CASE(structmember_extern); // No false positives for extern structs
|
||||
TEST_CASE(structmember10);
|
||||
|
||||
TEST_CASE(localvar1);
|
||||
TEST_CASE(localvar2);
|
||||
|
@ -297,6 +298,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void structmember10()
|
||||
{
|
||||
// Fred may have some useful side-effects
|
||||
checkStructMemberUsage("struct abc {\n"
|
||||
" Fred fred;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void structmember_extern()
|
||||
{
|
||||
// extern struct => no false positive
|
||||
|
|
Loading…
Reference in New Issue