Fix 10223: ValueFlow; known value for a volatile variable (#3658)
This commit is contained in:
parent
7bf0ca8d00
commit
0c952ca05d
|
@ -4883,6 +4883,12 @@ static void valueFlowForwardAssign(Token* const tok,
|
|||
if (vars.size() == 1 && vars.front()->isStatic() && init)
|
||||
lowerToPossible(values);
|
||||
|
||||
// is volatile
|
||||
if (std::any_of(vars.begin(), vars.end(), [&](const Variable* var) {
|
||||
return var->isVolatile();
|
||||
}))
|
||||
lowerToPossible(values);
|
||||
|
||||
// Skip RHS
|
||||
const Token * nextExpression = tok->astParent() ? nextAfterAstRightmostLeaf(tok->astParent()) : tok->next();
|
||||
|
||||
|
|
|
@ -3838,6 +3838,18 @@ private:
|
|||
" if (b) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #10223
|
||||
check("static volatile sig_atomic_t is_running;\n"
|
||||
"static void handler(int signum) {\n"
|
||||
" is_running = 0;\n"
|
||||
"}\n"
|
||||
"void f() {\n"
|
||||
" signal(SIGINT, &handler);\n"
|
||||
" is_running = 1;\n"
|
||||
" while (is_running) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void alwaysTrueSymbolic()
|
||||
|
|
Loading…
Reference in New Issue