Uninitialized variables: Fixed false positives when there are assembler code. Ticket: #3369
This commit is contained in:
parent
e5427fe487
commit
40f2f4f7f6
|
@ -1125,8 +1125,12 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const unsigned int
|
||||||
|
|
||||||
// TODO: handle loops, try, etc
|
// TODO: handle loops, try, etc
|
||||||
if (Token::simpleMatch(tok, ") {") || Token::Match(tok, "%var% {")) {
|
if (Token::simpleMatch(tok, ") {") || Token::Match(tok, "%var% {")) {
|
||||||
ret = true;
|
return true;
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
// bailout if there is assembler code
|
||||||
|
if (Token::simpleMatch(tok, "asm (")) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "return|break|continue|throw"))
|
if (Token::Match(tok, "return|break|continue|throw"))
|
||||||
|
|
|
@ -1823,6 +1823,14 @@ private:
|
||||||
" if (a) i++;\n"
|
" if (a) i++;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// asm
|
||||||
|
checkUninitVar2("void f() {\n"
|
||||||
|
" int x;\n"
|
||||||
|
" asm();\n"
|
||||||
|
" x++;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue