diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 0efc72a3b..f3314dc41 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1528,6 +1528,13 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all) done = false; } + // Reduce "{ loop ;" => ";" + if (Token::Match(tok2, "{ loop ;")) + { + tok2->deleteNext(); + done = false; + } + // Reduce "loop if break ; => ";" if (Token::Match(tok2->next(), "loop if break|continue ; !!else")) { diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index c348955eb..8a0798e4e 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -592,7 +592,9 @@ private: // switch.. ASSERT_EQUALS("; alloc ; dealloc ;", simplifycode(";alloc;switch{case;break;};dealloc;")); + ASSERT_EQUALS("; if return ; }", simplifycode("; switch { case ; return ; default ; break ; } }")); ASSERT_EQUALS("; if return ; else use ; }", simplifycode("; switch { case ; return ; default ; use ; break ; } }")); + ASSERT_EQUALS("; use ; }", simplifycode("; while1 { loop { ; } switch { case ; dealloc ; return ; default ; break ; } } }")); // loops.. ASSERT_EQUALS(";", simplifycode("; loop { break; }"));