Fix for #341 (Functions passed as pointer not detected as used)
This commit is contained in:
parent
2cbbc65691
commit
375dfeab06
|
@ -107,6 +107,9 @@ void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer)
|
|||
if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]"))
|
||||
funcname = tok->next();
|
||||
|
||||
if (Token::Match(tok, "[(,] & %var% :: %var% [,)]"))
|
||||
funcname = tok->tokAt(4);
|
||||
|
||||
// funcname ( => Assert that the end paranthesis isn't followed by {
|
||||
if (Token::Match(funcname, "%var% ("))
|
||||
{
|
||||
|
|
|
@ -39,6 +39,7 @@ private:
|
|||
TEST_CASE(return1);
|
||||
TEST_CASE(callback1);
|
||||
TEST_CASE(else1);
|
||||
TEST_CASE(functionpointer);
|
||||
}
|
||||
|
||||
void check(const char code[])
|
||||
|
@ -98,6 +99,20 @@ private:
|
|||
std::string err(errout.str());
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
}
|
||||
|
||||
void functionpointer()
|
||||
{
|
||||
check("namespace abc {\n"
|
||||
"void foo() { }\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"int main()\n"
|
||||
"{\n"
|
||||
" f(&abc::foo);\n"
|
||||
" return 0\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string(""), errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestFunctionUsage)
|
||||
|
|
Loading…
Reference in New Issue