Function Usage: Handling '.. else foo()'

This commit is contained in:
Daniel Marjamäki 2008-11-23 14:26:47 +00:00
parent 954371e3f8
commit c6264022f9
2 changed files with 14 additions and 1 deletions

View File

@ -97,6 +97,7 @@ 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, "|| %var% (") ||
TOKEN::Match(tok, "else %var% (") ||
TOKEN::Match(tok, "return %var% (") ) TOKEN::Match(tok, "return %var% (") )
funcname = tok->next; funcname = tok->next;

View File

@ -39,6 +39,7 @@ private:
TEST_CASE( incondition ); TEST_CASE( incondition );
TEST_CASE( return1 ); TEST_CASE( return1 );
TEST_CASE( callback1 ); TEST_CASE( callback1 );
TEST_CASE( else1 );
} }
void check( const char code[] ) void check( const char code[] )
@ -88,6 +89,17 @@ private:
std::string err( errout.str() ); std::string err( errout.str() );
ASSERT_EQUALS( std::string(""), errout.str() ); ASSERT_EQUALS( std::string(""), errout.str() );
} }
void else1()
{
check( "void f1()\n"
"{\n"
" if (cond) ;\n"
" else f1();\n"
"}\n" );
std::string err( errout.str() );
ASSERT_EQUALS( std::string(""), errout.str() );
}
}; };
REGISTER_TEST( TestFunctionUsage ) REGISTER_TEST( TestFunctionUsage )