Merge pull request #640 from Dmitry-Me/cacheAndReuse2

Cache and reuse value
This commit is contained in:
Daniel Marjamäki 2015-08-12 10:54:55 +02:00
commit 9df3aea83d
1 changed files with 2 additions and 2 deletions

View File

@ -2032,11 +2032,11 @@ static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symbol
if (!Token::Match(scope->classDef, "switch ( %var% ) {"))
continue;
const Token *vartok = scope->classDef->tokAt(2);
if (!vartok->variable())
const Variable *var = vartok->variable();
if (!var)
continue;
// bailout: global non-const variables
const Variable *var = vartok->variable();
if (!(var->isLocal() || var->isArgument()) && !var->isConst()) {
if (settings->debugwarnings)
bailout(tokenlist, errorLogger, vartok, "switch variable " + var->name() + " is global");