Variable usage : Fixed false positive with modulo

This commit is contained in:
Daniel Marjamäki 2009-01-04 16:42:10 +00:00
parent f8c44507e6
commit 445230f3ae
2 changed files with 14 additions and 1 deletions

View File

@ -809,7 +809,7 @@ static bool isOp(const Token *tok)
tok->str() == ">" ||
tok->str() == ">=" ||
tok->str() == "<<" ||
Token::Match(tok, "[+-*/&|,[])]")));
Token::Match(tok, "[+-*/%&|,[])]")));
}
void CheckOther::functionVariableUsage()

View File

@ -63,6 +63,8 @@ private:
TEST_CASE( localvar4 );
TEST_CASE( localvar5 );
TEST_CASE( localvar6 );
TEST_CASE( localvarMod ); // Usage with modulo
}
void structmember1()
@ -198,6 +200,17 @@ private:
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 )