Uninitialized variables: Fixed false positives when using sizeof inside loop

This commit is contained in:
Daniel Marjamäki 2013-03-22 08:10:46 +01:00
parent a79354d51c
commit c9469993e2
2 changed files with 10 additions and 0 deletions

View File

@ -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;
}

View File

@ -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() {