Fix 10362: ValueFlow: global variable might be modified by function call (#3358)
This commit is contained in:
parent
c14bb9cd2e
commit
14802b932e
|
@ -382,7 +382,7 @@ struct ForwardTraversal {
|
||||||
bool checkThen = true;
|
bool checkThen = true;
|
||||||
bool checkElse = false;
|
bool checkElse = false;
|
||||||
if (condTok && !Token::simpleMatch(condTok, ":"))
|
if (condTok && !Token::simpleMatch(condTok, ":"))
|
||||||
std::tie(checkThen, checkElse) = evalCond(condTok, isDoWhile ? endBlock->link()->previous() : nullptr);
|
std::tie(checkThen, checkElse) = evalCond(condTok, isDoWhile ? endBlock->previous() : nullptr);
|
||||||
if (checkElse && exit)
|
if (checkElse && exit)
|
||||||
return Progress::Continue;
|
return Progress::Continue;
|
||||||
// do while(false) is not really a loop
|
// do while(false) is not really a loop
|
||||||
|
|
|
@ -3671,6 +3671,23 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #10362
|
||||||
|
check("int tok;\n"
|
||||||
|
"void next();\n"
|
||||||
|
"void parse_attribute() {\n"
|
||||||
|
" if (tok == '(') {\n"
|
||||||
|
" int parenthesis = 0;\n"
|
||||||
|
" do {\n"
|
||||||
|
" if (tok == '(')\n"
|
||||||
|
" parenthesis++;\n"
|
||||||
|
" else if (tok == ')')\n"
|
||||||
|
" parenthesis--;\n"
|
||||||
|
" next();\n"
|
||||||
|
" } while (parenthesis && tok != -1);\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void alwaysTrueInfer() {
|
void alwaysTrueInfer() {
|
||||||
|
|
Loading…
Reference in New Issue