Variable usage : Fixed false positive with modulo
This commit is contained in:
parent
f8c44507e6
commit
445230f3ae
|
@ -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()
|
||||||
|
|
|
@ -63,6 +63,8 @@ private:
|
||||||
TEST_CASE( localvar4 );
|
TEST_CASE( localvar4 );
|
||||||
TEST_CASE( localvar5 );
|
TEST_CASE( localvar5 );
|
||||||
TEST_CASE( localvar6 );
|
TEST_CASE( localvar6 );
|
||||||
|
|
||||||
|
TEST_CASE( localvarMod ); // Usage with modulo
|
||||||
}
|
}
|
||||||
|
|
||||||
void structmember1()
|
void structmember1()
|
||||||
|
@ -198,6 +200,17 @@ private:
|
||||||
ASSERT_EQUALS( std::string(""), errout.str() );
|
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void localvarMod()
|
||||||
|
{
|
||||||
|
functionVariableUsage( "int main()\n"
|
||||||
|
"{\n"
|
||||||
|
" int tmp = 10;\n"
|
||||||
|
" return 123 % tmp;\n"
|
||||||
|
"}\n" );
|
||||||
|
ASSERT_EQUALS( std::string(""), errout.str() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST( TestUnusedVar )
|
REGISTER_TEST( TestUnusedVar )
|
||||||
|
|
Loading…
Reference in New Issue