diff --git a/src/checkfunctionusage.cpp b/src/checkfunctionusage.cpp index 1020a8505..765164ac7 100644 --- a/src/checkfunctionusage.cpp +++ b/src/checkfunctionusage.cpp @@ -99,17 +99,18 @@ void CheckFunctionUsage::parseTokens(const Tokenizer &tokenizer) if (Token::Match(tok->next(), "%var% (")) { - if (tok->str() == "*" || (tok->isName() && !Token::Match(tok, "else|return"))) - continue; funcname = tok->next(); } - if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]")) + else if (Token::Match(tok, "[;{}.,()[=+-/&|!?:] %var% [(),;:}]")) funcname = tok->next(); - if (Token::Match(tok, "[(,] & %var% :: %var% [,)]")) + else if (Token::Match(tok, "[(,] & %var% :: %var% [,)]")) funcname = tok->tokAt(4); + else + continue; + // funcname ( => Assert that the end paranthesis isn't followed by { if (Token::Match(funcname, "%var% (")) { diff --git a/test/testfunctionusage.cpp b/test/testfunctionusage.cpp index 78cca6b11..1a9bc561a 100644 --- a/test/testfunctionusage.cpp +++ b/test/testfunctionusage.cpp @@ -37,6 +37,7 @@ private: { TEST_CASE(incondition); TEST_CASE(return1); + TEST_CASE(return2); TEST_CASE(callback1); TEST_CASE(else1); TEST_CASE(functionpointer); @@ -79,6 +80,15 @@ private: ASSERT_EQUALS("", errout.str()); } + void return2() + { + check("char * foo()\n" + "{\n" + " return *foo();\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void callback1() { check("void f1()\n"