diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 6fc8bc9f3..5acce1028 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1766,13 +1766,6 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok) done = false; } - // Reduce "[;{}] return ; %var%" => "[;{}] return ;" - if (Token::Match(tok2, "[;{}] return ; %var%")) - { - Token::eraseTokens(tok2->tokAt(2), tok2->tokAt(4)); - done = false; - } - // Reduce "[;{}] return use ; %var%" => "[;{}] return use ;" if (Token::Match(tok2, "[;{}] return use ; %var%")) { diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 9fa6f7453..b8fa24109 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -658,6 +658,7 @@ private: ASSERT_EQUALS("; if return ;", simplifycode("; switch { case ; if { return ; } break ; 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 ; } }")); + ASSERT_EQUALS("; { dealloc ; return ; } }", simplifycode("switch { case ; case ; dealloc ; return ; default ; dealloc ; return ; } }")); // loops.. ASSERT_EQUALS(";", simplifycode("; loop { ; }"));