From 24703418bd89e91493f6a8082692286ee77af254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 29 May 2010 20:55:09 +0200 Subject: [PATCH] Fixed #1715 (switch with fallthrough and 'return' confuses cppcheck) --- lib/checkmemoryleak.cpp | 7 ------- test/testmemleak.cpp | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) 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 { ; }"));