Unreachable code : Fixed false positives for label
This commit is contained in:
parent
4d070f04e5
commit
4ef7839d6a
|
@ -800,12 +800,15 @@ void CheckOther::unreachableCode()
|
||||||
const TOKEN *tok = TOKEN::findmatch( _tokenizer->tokens(), "[;{}] return" );
|
const TOKEN *tok = TOKEN::findmatch( _tokenizer->tokens(), "[;{}] return" );
|
||||||
while ( tok )
|
while ( tok )
|
||||||
{
|
{
|
||||||
|
// Goto the 'return' token
|
||||||
|
tok = tok->next;
|
||||||
|
|
||||||
// Locate the end of the 'return' statement
|
// Locate the end of the 'return' statement
|
||||||
while ( tok && ! TOKEN::Match(tok, ";") )
|
while ( tok && ! TOKEN::Match(tok, ";") )
|
||||||
tok = tok->next;
|
tok = tok->next;
|
||||||
|
|
||||||
// Next token should be either "case", "default" or "}"
|
// If there is a statement below the return it is unreachable
|
||||||
if (tok && tok->next && !TOKEN::Match( tok, "; case|default|}"))
|
if (!TOKEN::Match(tok, "; case|default|}") && !TOKEN::Match(tok, "; %var% :"))
|
||||||
{
|
{
|
||||||
std::ostringstream errmsg;
|
std::ostringstream errmsg;
|
||||||
errmsg << _tokenizer->fileLine(tok->next) << ": Unreachable code below a 'return'";
|
errmsg << _tokenizer->fileLine(tok->next) << ": Unreachable code below a 'return'";
|
||||||
|
|
Loading…
Reference in New Issue