Function usage : Fixed false positives for inline structs
This commit is contained in:
parent
68d08b73b6
commit
dd914c0089
|
@ -842,6 +842,14 @@ void CheckOther::functionVariableUsage()
|
|||
if ( indentlevel <= 0 )
|
||||
break;
|
||||
}
|
||||
else if ( Token::simpleMatch(tok, "struct {") )
|
||||
{
|
||||
while ( tok && tok->str() != "}" )
|
||||
tok = tok->next();
|
||||
if ( tok )
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( Token::Match(tok, "[;{}] bool|char|short|int|long|float|double %var% ;|=") )
|
||||
varUsage[ tok->strAt(2) ] = USAGE_DECLARE;
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
TEST_CASE( localvar3 );
|
||||
TEST_CASE( localvar4 );
|
||||
TEST_CASE( localvar5 );
|
||||
TEST_CASE( localvar6 );
|
||||
}
|
||||
|
||||
void structmember1()
|
||||
|
@ -186,6 +187,17 @@ private:
|
|||
"}\n" );
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
|
||||
void localvar6()
|
||||
{
|
||||
functionVariableUsage( "void foo()\n"
|
||||
"{\n"
|
||||
" static const struct{ int x, y, w, h; } bounds = {1,2,3,4};\n"
|
||||
" return bounds.x + bounds.y + bounds.w + bounds.h;\n"
|
||||
"}\n" );
|
||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
REGISTER_TEST( TestUnusedVar )
|
||||
|
|
Loading…
Reference in New Issue