Uninitialized variables: Fixed false positives when using sizeof inside loop
This commit is contained in:
parent
a79354d51c
commit
c9469993e2
|
@ -1462,6 +1462,9 @@ bool CheckUninitVar::checkLoopBody(const Token *tok, const Variable& var, const
|
|||
}
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "sizeof|typeof ("))
|
||||
tok = tok->next()->link();
|
||||
|
||||
if (Token::Match(tok, "asm ( %str% ) ;"))
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2812,6 +2812,13 @@ private:
|
|||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("static void f(void) {\n"
|
||||
" struct ABC *abc;\n"
|
||||
" for (i = 0; i < 10; i++)\n"
|
||||
" x += sizeof(*abc);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar2_4494() {
|
||||
|
|
Loading…
Reference in New Issue