Dont follow volatile variables (#1365)

This commit is contained in:
Paul Fultz II 2018-09-03 12:51:48 -05:00 committed by Daniel Marjamäki
parent 220c06e356
commit 0e5fabf4dc
2 changed files with 6 additions and 0 deletions

View File

@ -175,6 +175,8 @@ static const Token * followVariableExpression(const Token * tok, bool cpp)
// Skip array access
if (Token::simpleMatch(varTok, "["))
return tok;
if (var->isVolatile())
return tok;
if (!var->isLocal() && !var->isConst())
return tok;
if (var->isStatic() && !var->isConst())

View File

@ -4075,6 +4075,10 @@ private:
" if(a == 1) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("volatile const int var = 42;\n"
"void f() { if(var == 42) {} }\n");
ASSERT_EQUALS("", errout.str());
}
void duplicateExpressionLoop() {