Fixed #1479 (false positive: unintialized variable when using goto)
This commit is contained in:
parent
3507b06e0b
commit
734b10e650
|
@ -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"))
|
||||
{
|
||||
|
|
|
@ -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..
|
||||
|
|
Loading…
Reference in New Issue