Fixed #1216 (false positive: uninitialized variable when using exit|abort)

This commit is contained in:
Daniel Marjamäki 2010-01-03 15:35:32 +01:00
parent fa535ff3ae
commit e286896d75
2 changed files with 14 additions and 0 deletions

View File

@ -95,6 +95,12 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list<ExecutionPa
return 0;
}
if (Token::Match(tok, "abort|exit ("))
{
ExecutionPath::bailOut(checks);
return 0;
}
// don't parse into "struct type { .."
if (Token::Match(tok, "struct %type% {"))
tok = tok->tokAt(2)->link();

View File

@ -954,6 +954,14 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkNullPointer("static void foo()\n"
"{\n"
" int *p = 0;\n"
" exit();\n"
" *p = 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkNullPointer("static void foo(int a)\n"
"{\n"
" Foo *p = 0;\n"