Fixed #3570 (False Postive for 'nullPointer' check)
This commit is contained in:
parent
f9ade9562c
commit
036b2a84bf
|
@ -1221,7 +1221,7 @@ private:
|
|||
/** parse condition. @sa ExecutionPath::parseCondition */
|
||||
bool parseCondition(const Token &tok, std::list<ExecutionPath *> &checks) {
|
||||
for (const Token *tok2 = &tok; tok2; tok2 = tok2->next()) {
|
||||
if (tok2->str() == "(" || tok2->str() == ")")
|
||||
if (tok2->str() == "(" || tok2->str() == ")" || tok2->str() == "&&" || tok2->str() == "||")
|
||||
break;
|
||||
bool unknown = owner->inconclusiveFlag();
|
||||
if (tok2->varId() && (CheckNullPointer::isPointerDeRef(tok2, unknown, symbolDatabase) || unknown))
|
||||
|
|
|
@ -978,6 +978,31 @@ private:
|
|||
" fred->do_something();\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ticket #3570 - parsing of conditions
|
||||
{
|
||||
check("void f() {\n"
|
||||
" int *p = NULL;\n"
|
||||
" if (x)\n"
|
||||
" p = q;\n"
|
||||
" if (p && *p) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
check("void f() {\n"
|
||||
" int *p = NULL;\n"
|
||||
" if (x)\n"
|
||||
" p = q;\n"
|
||||
" if (!p || *p) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
check("void f() {\n"
|
||||
" int *p = NULL;\n"
|
||||
" if (x)\n"
|
||||
" p = q;\n"
|
||||
" if (p || *p) { }\n"
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("error", "", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
// Ticket #2350
|
||||
|
|
Loading…
Reference in New Issue