Fixed #5658 (false positive: (error) Uninitialized variable: s)
This commit is contained in:
parent
baf8d09a0d
commit
c8ae1e4751
|
@ -1607,7 +1607,10 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
|
|||
assign = false;
|
||||
break;
|
||||
} else if (tok2->str() == "(") {
|
||||
++indentlevel;
|
||||
if (Token::Match(tok2->astOperand1(), "sizeof"))
|
||||
tok2 = tok2->link();
|
||||
else
|
||||
++indentlevel;
|
||||
} else if (tok2->str() == ")") {
|
||||
if (indentlevel <= 1U)
|
||||
break;
|
||||
|
|
|
@ -3265,6 +3265,15 @@ private:
|
|||
" }\n"
|
||||
"}");
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue