Fixed #1202 (false positive: uninitialized variable when using 'do')
This commit is contained in:
parent
6af5e434d8
commit
2e62a3f4c7
|
@ -66,7 +66,7 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list<ExecutionPa
|
|||
return 0;
|
||||
|
||||
// todo: handle for/while
|
||||
if (Token::Match(tok, "for|while|switch"))
|
||||
if (Token::Match(tok, "for|while|switch|do"))
|
||||
{
|
||||
ExecutionPath::bailOut(checks);
|
||||
return 0;
|
||||
|
|
|
@ -1267,6 +1267,19 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("int f(int a, int b)\n"
|
||||
"{\n"
|
||||
" int x;\n"
|
||||
" if (a)\n"
|
||||
" x = a;\n"
|
||||
" else {\n"
|
||||
" do { } while (f2());\n"
|
||||
" x = b;\n"
|
||||
" }\n"
|
||||
" return x;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// switch..
|
||||
checkUninitVar("char * f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue