Fix #884 (False positive: Possible null pointer reference about a non-pointer)
http://sourceforge.net/apps/trac/cppcheck/ticket/884
This commit is contained in:
parent
543d5cbf45
commit
eebbc1b906
|
@ -1160,7 +1160,11 @@ void CheckOther::nullPointerConditionalAssignment()
|
|||
if (Token::Match(tok2, "%varid%", varid))
|
||||
{
|
||||
if (Token::Match(tok2, "%varid% . %var% (", varid))
|
||||
{
|
||||
const Token *tempTok = Token::findmatch(_tokenizer->tokens(), "%type% * %varid% [;)=]", varid);
|
||||
if (tempTok)
|
||||
nullPointerError(tok2, tok->next()->str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ private:
|
|||
TEST_CASE(nullpointer4);
|
||||
TEST_CASE(nullpointer5); // References should not be checked
|
||||
TEST_CASE(nullpointer6);
|
||||
TEST_CASE(nullpointer7);
|
||||
|
||||
TEST_CASE(uninitvar1);
|
||||
|
||||
|
@ -921,7 +922,15 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void nullpointer7()
|
||||
{
|
||||
checkNullPointer("void foo()\n"
|
||||
"{\n"
|
||||
" wxLongLong x = 0;\n"
|
||||
" int y = x.GetValue();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkUninitVar(const char code[])
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue