unused struct member: fixed false positive for member "const int a;"
This commit is contained in:
parent
a2a8378749
commit
1a4cfc6c4f
|
@ -663,7 +663,7 @@ void CheckOther::CheckStructMemberUsage()
|
|||
if (Token::Match(tok->next(), "%type% %var% [;[]"))
|
||||
varname = tok->strAt(2);
|
||||
else if (Token::Match(tok->next(), "%type% %type% %var% [;[]"))
|
||||
varname = tok->strAt(2);
|
||||
varname = tok->strAt(3);
|
||||
else if (Token::Match(tok->next(), "%type% * %var% [;[]"))
|
||||
varname = tok->strAt(3);
|
||||
else if (Token::Match(tok->next(), "%type% %type% * %var% [;[]"))
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
TEST_CASE(structmember1);
|
||||
TEST_CASE(structmember2);
|
||||
TEST_CASE(structmember3);
|
||||
TEST_CASE(structmember4);
|
||||
|
||||
TEST_CASE(localvar1);
|
||||
TEST_CASE(localvar2);
|
||||
|
@ -127,6 +128,22 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void structmember4()
|
||||
{
|
||||
check("struct ABC\n"
|
||||
"{\n"
|
||||
" const int a;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void foo()\n"
|
||||
"{\n"
|
||||
" ABC abc;\n"
|
||||
" if (abc.a == 2);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue