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;")); }