Fixed #1479 (false positive: unintialized variable when using goto)

This commit is contained in:
Daniel Marjamäki 2010-04-02 08:35:05 +02:00
parent 3507b06e0b
commit 734b10e650
2 changed files with 16 additions and 0 deletions

View File

@ -91,6 +91,13 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list<ExecutionPa
}
}
// goto => bailout
if (tok->str() == "goto")
{
ExecutionPath::bailOut(checks);
return 0;
}
// for/while/switch/do .. bail out
if (Token::Match(tok, "for|while|switch|do"))
{

View File

@ -1390,6 +1390,15 @@ private:
" return retval;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("int foo()\n"
"{\n"
" int i;\n"
" goto exit;\n"
" i++;\n"
"exit:\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
// if..