Tokenizer: Fixed calculation simplification of '0*(*p)'. Ticket: #2348

This commit is contained in:
Daniel Marjamäki 2010-12-23 18:59:18 +01:00
parent aff3623fec
commit 472ecd8805
2 changed files with 4 additions and 0 deletions

View File

@ -6607,6 +6607,8 @@ bool Tokenizer::simplifyCalculations()
else if (Token::Match(tok->previous(), "[=[(,] 0 * %any% [+-*/,]);]")) else if (Token::Match(tok->previous(), "[=[(,] 0 * %any% [+-*/,]);]"))
{ {
tok->deleteNext(); tok->deleteNext();
if (tok->next()->str() == "(")
Token::eraseTokens(tok, tok->next()->link());
tok->deleteNext(); tok->deleteNext();
ret = true; ret = true;
} }

View File

@ -2566,6 +2566,8 @@ private:
ASSERT_EQUALS("void * operator new [ ] ( size_t ) ;", tok(code)); ASSERT_EQUALS("void * operator new [ ] ( size_t ) ;", tok(code));
} }
ASSERT_EQUALS("; a [ 0 ] ;", tok(";a[0*(*p)];"));
ASSERT_EQUALS(";", tok("; x = x + 0;")); ASSERT_EQUALS(";", tok("; x = x + 0;"));
} }