Function usage: Handling callbacks better: 'void (*f)() = cond ? foo : NULL'
This commit is contained in:
parent
bb46a0cc42
commit
954371e3f8
|
@ -91,7 +91,7 @@ void CheckFunctionUsage::parseTokens( const Tokenizer &tokenizer )
|
|||
{
|
||||
const TOKEN *funcname = 0;
|
||||
|
||||
if ( TOKEN::Match( tok, "[;{}.,()[=+-/&|] %var% [(),;]" ) ||
|
||||
if ( TOKEN::Match( tok, "[;{}.,()[=+-/&|?:] %var% [(),;:]" ) ||
|
||||
TOKEN::Match(tok, ":: %var% (") ||
|
||||
TOKEN::Match(tok, "|= %var% (") ||
|
||||
TOKEN::Match(tok, "&= %var% (") ||
|
||||
|
|
|
@ -38,6 +38,7 @@ private:
|
|||
{
|
||||
TEST_CASE( incondition );
|
||||
TEST_CASE( return1 );
|
||||
TEST_CASE( callback1 );
|
||||
}
|
||||
|
||||
void check( const char code[] )
|
||||
|
@ -77,6 +78,16 @@ private:
|
|||
std::string err( errout.str() );
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
|
||||
void callback1()
|
||||
{
|
||||
check( "void f1()\n"
|
||||
"{\n"
|
||||
" void (*f)() = cond ? f1 : NULL;\n"
|
||||
"}\n" );
|
||||
std::string err( errout.str() );
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST( TestFunctionUsage )
|
||||
|
|
Loading…
Reference in New Issue