Fixed #1715 (switch with fallthrough and 'return' confuses cppcheck)

This commit is contained in:
Daniel Marjamäki 2010-05-29 20:55:09 +02:00
parent d09e1df0d7
commit 24703418bd
2 changed files with 1 additions and 7 deletions

View File

@ -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%"))
{

View File

@ -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 { ; }"));