value flow: stop checking global variable when going out of function scope

This commit is contained in:
Daniel Marjamäki 2014-01-10 16:17:19 +01:00
parent acb103e214
commit 3e7f692d4d
1 changed files with 7 additions and 1 deletions

View File

@ -137,7 +137,13 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog
} else {
tok2 = tok2->link();
}
}
} else if (var->isGlobal() && tok2->str() == "{") {
if (!Token::Match(tok2->previous(), ")|else {"))
break;
if (Token::Match(tok2->previous(), ") {") &&
!Token::Match(tok2->linkAt(-1)->previous(), "if|for|while ("))
break;
}
}
}
}