diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d79a2fd05..f55423a45 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4079,7 +4079,7 @@ bool Tokenizer::simplifyKnownVariables() for (const Token *tok4 = tok3; tok4 && tok4 != endpar; tok4 = tok4->next()) { if (Token::Match(tok4, "++|-- %varid%", varid) || - Token::Match(tok4, "%varid% ++|--", varid)) + Token::Match(tok4, "%varid% ++|--|=", varid)) { bailout = true; break; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index b30b05361..547566aab 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -93,6 +93,7 @@ private: TEST_CASE(simplifyKnownVariables16); TEST_CASE(simplifyKnownVariables17); TEST_CASE(simplifyKnownVariables18); + TEST_CASE(simplifyKnownVariables19); TEST_CASE(match1); @@ -979,6 +980,14 @@ private: simplifyKnownVariables(code)); } + void simplifyKnownVariables19() + { + const char code[] = "void f ( ) { int i=0; do { if (i>0) { a(); } i=b(); } while (i != 12); }"; + ASSERT_EQUALS( + "void f ( ) { int i ; i = 0 ; do { if ( 0 < i ) { a ( ) ; } i = b ( ) ; } while ( i != 12 ) ; }", + simplifyKnownVariables(code)); + } + void match1() { // Match "%var% | %var%"