unused struct member: fixed false positive for member "const int a;"

This commit is contained in:
Daniel Marjamäki 2009-01-10 14:39:20 +00:00
parent a2a8378749
commit 1a4cfc6c4f
2 changed files with 18 additions and 1 deletions

View File

@ -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% [;[]"))

View File

@ -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());
}