Variable usage: Fixed false positive with operators ~ and !
This commit is contained in:
parent
9ea852eb0e
commit
dcc15d7f22
|
@ -809,7 +809,7 @@ static bool isOp(const Token *tok)
|
||||||
tok->str() == ">" ||
|
tok->str() == ">" ||
|
||||||
tok->str() == ">=" ||
|
tok->str() == ">=" ||
|
||||||
tok->str() == "<<" ||
|
tok->str() == "<<" ||
|
||||||
Token::Match(tok, "[+-*/%&|,[])?:]")));
|
Token::Match(tok, "[+-*/%&!~|,[])?:]")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckOther::functionVariableUsage()
|
void CheckOther::functionVariableUsage()
|
||||||
|
|
|
@ -65,6 +65,7 @@ private:
|
||||||
TEST_CASE( localvar6 );
|
TEST_CASE( localvar6 );
|
||||||
|
|
||||||
TEST_CASE( localvarMod ); // Usage with modulo
|
TEST_CASE( localvarMod ); // Usage with modulo
|
||||||
|
TEST_CASE( localvarInvert ); // Usage with inverted variable
|
||||||
TEST_CASE( localvarIf ); // Usage in if
|
TEST_CASE( localvarIf ); // Usage in if
|
||||||
TEST_CASE( localvarIfElse ); // return tmp1 ? tmp2 : tmp3;
|
TEST_CASE( localvarIfElse ); // return tmp1 ? tmp2 : tmp3;
|
||||||
}
|
}
|
||||||
|
@ -212,6 +213,16 @@ private:
|
||||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void localvarInvert()
|
||||||
|
{
|
||||||
|
functionVariableUsage( "int main()\n"
|
||||||
|
"{\n"
|
||||||
|
" int tmp = 10;\n"
|
||||||
|
" return ~tmp;\n"
|
||||||
|
"}\n" );
|
||||||
|
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||||
|
}
|
||||||
|
|
||||||
void localvarIf()
|
void localvarIf()
|
||||||
{
|
{
|
||||||
functionVariableUsage( "int main()\n"
|
functionVariableUsage( "int main()\n"
|
||||||
|
|
Loading…
Reference in New Issue