Fixed #1715 (switch with fallthrough and 'return' confuses cppcheck)
This commit is contained in:
parent
d09e1df0d7
commit
24703418bd
|
@ -1766,13 +1766,6 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
|
||||||
done = false;
|
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 ;"
|
// Reduce "[;{}] return use ; %var%" => "[;{}] return use ;"
|
||||||
if (Token::Match(tok2, "[;{}] return use ; %var%"))
|
if (Token::Match(tok2, "[;{}] return use ; %var%"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -658,6 +658,7 @@ private:
|
||||||
ASSERT_EQUALS("; if return ;", simplifycode("; switch { case ; if { return ; } break ; default ; break ; }"));
|
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("; 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("; use ;", simplifycode("; while1 { loop { ; } switch { case ; dealloc ; return ; default ; break ; } }"));
|
||||||
|
ASSERT_EQUALS("; { dealloc ; return ; } }", simplifycode("switch { case ; case ; dealloc ; return ; default ; dealloc ; return ; } }"));
|
||||||
|
|
||||||
// loops..
|
// loops..
|
||||||
ASSERT_EQUALS(";", simplifycode("; loop { ; }"));
|
ASSERT_EQUALS(";", simplifycode("; loop { ; }"));
|
||||||
|
|
Loading…
Reference in New Issue