Fix another FP with range for macro (#3276)
This commit is contained in:
parent
a4653a057a
commit
5f0fe1dfe7
|
@ -1909,6 +1909,9 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings,
|
|||
}
|
||||
|
||||
if (Token::simpleMatch(tok2->astParent(), ":") && tok2->astParent()->astParent() && Token::simpleMatch(tok2->astParent()->astParent()->previous(), "for (")) {
|
||||
// TODO: Check if container is empty or not
|
||||
if (astIsLHS(tok2))
|
||||
return true;
|
||||
const Token * varTok = tok2->astParent()->previous();
|
||||
if (!varTok)
|
||||
return false;
|
||||
|
|
|
@ -1528,8 +1528,6 @@ void CheckUninitVar::valueFlowUninit()
|
|||
continue;
|
||||
if (v->indirect > 1 || v->indirect < 0)
|
||||
continue;
|
||||
if (v->indirect == 0 && !isVariableUsage(tok, tok->valueType() && tok->valueType()->pointer > 0, NO_ALLOC))
|
||||
continue;
|
||||
bool uninitderef = false;
|
||||
if (tok->variable()) {
|
||||
bool unknown;
|
||||
|
|
|
@ -4646,6 +4646,16 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
valueFlowUninit("X f() {\n"
|
||||
" if (!itemList.empty()) {\n"
|
||||
" X* item;\n"
|
||||
" for(item: itemList) {}\n"
|
||||
" return *item;\n"
|
||||
" }\n"
|
||||
" return X{};\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// macro_for..
|
||||
valueFlowUninit("int foo()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue