Fixed #1202 (false positive: uninitialized variable when using 'do')

This commit is contained in:
Daniel Marjamäki 2010-01-02 09:08:36 +01:00
parent 6af5e434d8
commit 2e62a3f4c7
2 changed files with 14 additions and 1 deletions

View File

@ -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;

View File

@ -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"