Function usage: handling 'return foo();' better
This commit is contained in:
parent
2db9c34d24
commit
bb46a0cc42
|
@ -96,7 +96,8 @@ void CheckFunctionUsage::parseTokens( const Tokenizer &tokenizer )
|
|||
TOKEN::Match(tok, "|= %var% (") ||
|
||||
TOKEN::Match(tok, "&= %var% (") ||
|
||||
TOKEN::Match(tok, "&& %var% (") ||
|
||||
TOKEN::Match(tok, "|| %var% (") )
|
||||
TOKEN::Match(tok, "|| %var% (") ||
|
||||
TOKEN::Match(tok, "return %var% (") )
|
||||
funcname = tok->next;
|
||||
|
||||
// funcname ( => Assert that the end paranthesis isn't followed by {
|
||||
|
|
|
@ -37,6 +37,7 @@ private:
|
|||
void run()
|
||||
{
|
||||
TEST_CASE( incondition );
|
||||
TEST_CASE( return1 );
|
||||
}
|
||||
|
||||
void check( const char code[] )
|
||||
|
@ -59,11 +60,6 @@ private:
|
|||
void incondition()
|
||||
{
|
||||
check( "int f1()\n"
|
||||
"{\n"
|
||||
" f2();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void f2()\n"
|
||||
"{\n"
|
||||
" if (f1())\n"
|
||||
" { }\n"
|
||||
|
@ -71,6 +67,16 @@ private:
|
|||
std::string err( errout.str() );
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
|
||||
void return1()
|
||||
{
|
||||
check( "int f1()\n"
|
||||
"{\n"
|
||||
" return f1();\n"
|
||||
"}\n" );
|
||||
std::string err( errout.str() );
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST( TestFunctionUsage )
|
||||
|
|
Loading…
Reference in New Issue