Fixed #5658 (false positive: (error) Uninitialized variable: s)
This commit is contained in:
parent
baf8d09a0d
commit
c8ae1e4751
|
@ -1607,6 +1607,9 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
|
||||||
assign = false;
|
assign = false;
|
||||||
break;
|
break;
|
||||||
} else if (tok2->str() == "(") {
|
} else if (tok2->str() == "(") {
|
||||||
|
if (Token::Match(tok2->astOperand1(), "sizeof"))
|
||||||
|
tok2 = tok2->link();
|
||||||
|
else
|
||||||
++indentlevel;
|
++indentlevel;
|
||||||
} else if (tok2->str() == ")") {
|
} else if (tok2->str() == ")") {
|
||||||
if (indentlevel <= 1U)
|
if (indentlevel <= 1U)
|
||||||
|
|
|
@ -3265,6 +3265,15 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar2("void f(void) {\n" // #5658
|
||||||
|
" struct Foo *foo;\n"
|
||||||
|
" while (true) {\n"
|
||||||
|
" foo = malloc(sizeof(*foo));\n"
|
||||||
|
" foo->x = 0;\n"
|
||||||
|
" }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitvar2_4494() {
|
void uninitvar2_4494() {
|
||||||
|
|
Loading…
Reference in New Issue