Uninitialized variables: Fixed false positives when there are assembler code. Ticket: #3369

This commit is contained in:
Daniel Marjamäki 2011-12-15 20:29:57 +01:00
parent e5427fe487
commit 40f2f4f7f6
2 changed files with 14 additions and 2 deletions

View File

@ -1125,8 +1125,12 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const unsigned int
// TODO: handle loops, try, etc
if (Token::simpleMatch(tok, ") {") || Token::Match(tok, "%var% {")) {
ret = true;
return false;
return true;
}
// bailout if there is assembler code
if (Token::simpleMatch(tok, "asm (")) {
return true;
}
if (Token::Match(tok, "return|break|continue|throw"))

View File

@ -1823,6 +1823,14 @@ private:
" if (a) i++;\n"
"}");
ASSERT_EQUALS("", errout.str());
// asm
checkUninitVar2("void f() {\n"
" int x;\n"
" asm();\n"
" x++;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};