Fixed #2695 (False positive: null pointer dereference and ternary operator (?:))

This commit is contained in:
Daniel Marjamäki 2011-03-29 18:45:32 +02:00
parent b31da161a7
commit 0a2f11c2cd
2 changed files with 15 additions and 2 deletions

View File

@ -444,8 +444,8 @@ void CheckNullPointer::nullPointerStructByDeRefAndChec()
--indentlevel2;
}
// label. goto destination..
else if (tok2->isName() && Token::simpleMatch(tok2->next(), ":"))
// label / ?:
else if (tok2->str() == ":")
break;
// Reassignment of the struct

View File

@ -493,6 +493,19 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
check("int f(Item *item) {\n"
" x = item ? ab(item->x) : 0;\n"
" if (item) { }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("int f(Item *item) {\n"
" item->x = 0;\n"
" a = b ? c : d;\n"
" if (item) { }\n"
"}\n");
TODO_ASSERT_EQUALS("error", "", errout.str());
check("BOOL GotoFlyAnchor()\n" // #2243
"{\n"
" const SwFrm* pFrm = GetCurrFrm();\n"