diff --git a/src/tokenize.cpp b/src/tokenize.cpp index f12939401..29ced3702 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -3022,7 +3022,7 @@ bool Tokenizer::simplifyKnownVariables() } // Stop if something like 'while (--var)' is found - if (tok3->str() == "while") + if (tok3->str() == "while" || tok3->str() == "do") { const Token *endpar = tok3->next()->link(); bool bailout = false; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 58160e3ed..672875269 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -80,6 +80,7 @@ private: TEST_CASE(simplifyKnownVariables11); TEST_CASE(simplifyKnownVariables12); TEST_CASE(simplifyKnownVariables13); + TEST_CASE(simplifyKnownVariables14); TEST_CASE(match1); @@ -802,6 +803,13 @@ private: simplifyKnownVariables(code)); } + void simplifyKnownVariables14() + { + // ticket #753 + const char code[] = "void f ( ) { int n ; n = 1 ; do { ++ n ; } while ( n < 10 ) ; }"; + ASSERT_EQUALS(code, simplifyKnownVariables(code)); + } + void match1() {