diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index bf576d943..6214518ac 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2978,6 +2978,8 @@ bool Tokenizer::simplifyTokenList() simplifyNestedStrcat(); simplifyWhile0(); + simplifyIfAssign(); // could be affected by simplifyIfNot + for (Token *tok = _tokens; tok; tok = tok->next()) { if (Token::Match(tok, "case %any% : %var%")) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 9961eecd9..7a73b593b 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1700,6 +1700,8 @@ private: tok("struct hfs_bnode *node;" "struct hfs_btree *tree;" "while ((node = tree->node_hash[i++])) { }")); + ASSERT_EQUALS("char * s ; s = new char [ 10 ] ; while ( ! s ) { s = new char [ 10 ] ; }", + tok("char *s; while (0 == (s=new char[10])) { }")); }