Dont follow volatile variables (#1365)
This commit is contained in:
parent
220c06e356
commit
0e5fabf4dc
|
@ -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())
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue