From 472ecd8805f9e5ac237fe7bba4217ce667f8c688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 23 Dec 2010 18:59:18 +0100 Subject: [PATCH] Tokenizer: Fixed calculation simplification of '0*(*p)'. Ticket: #2348 --- lib/tokenize.cpp | 2 ++ test/testsimplifytokens.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d3086036d..1994eb5f7 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6607,6 +6607,8 @@ bool Tokenizer::simplifyCalculations() else if (Token::Match(tok->previous(), "[=[(,] 0 * %any% [+-*/,]);]")) { tok->deleteNext(); + if (tok->next()->str() == "(") + Token::eraseTokens(tok, tok->next()->link()); tok->deleteNext(); ret = true; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index abf8cd923..672841070 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -2566,6 +2566,8 @@ private: ASSERT_EQUALS("void * operator new [ ] ( size_t ) ;", tok(code)); } + ASSERT_EQUALS("; a [ 0 ] ;", tok(";a[0*(*p)];")); + ASSERT_EQUALS(";", tok("; x = x + 0;")); }