Fixed #950 (Bug in cppcheck tokenize.cpp)

This commit is contained in:
Daniel Marjamäki 2009-11-12 18:53:26 +01:00
parent 050e8400b0
commit c337b4eb33
2 changed files with 11 additions and 0 deletions

View File

@ -4609,6 +4609,8 @@ void Tokenizer::simplifyComparisonOrder()
{
if (Token::Match(tok, "[;(] %any% >|>= %any% [);]"))
{
if (!tok->next()->isName() && !tok->next()->isNumber())
continue;
const std::string op1(tok->strAt(1));
tok->next()->str(tok->strAt(3));
tok->tokAt(3)->str(op1);

View File

@ -39,6 +39,8 @@ private:
void run()
{
TEST_CASE(tokenize1);
TEST_CASE(minus);
TEST_CASE(longtok);
@ -210,6 +212,13 @@ private:
}
void tokenize1()
{
const std::string code("void f ( )\n"
"{ if ( p . y ( ) > yof ) { } }");
ASSERT_EQUALS(code, tokenizeAndStringify(code.c_str()));
}
void minus()
{
ASSERT_EQUALS("i = -12", tokenizeAndStringify("i = -12"));