Fixed #1265 ((error) Uninitialized variable on macro expansion)

This commit is contained in:
Daniel Marjamäki 2010-01-13 19:37:55 +01:00
parent 0212225859
commit cefa695dba
2 changed files with 9 additions and 3 deletions

View File

@ -140,11 +140,9 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list<ExecutionPa
if (Token::Match(tok, "struct %type% {")) if (Token::Match(tok, "struct %type% {"))
tok = tok->tokAt(2)->link(); tok = tok->tokAt(2)->link();
if (Token::Match(tok, "= {") || Token::Match(tok, "= ( %type% !!=")) if (Token::Match(tok, "= {"))
{ {
tok = tok->next()->link(); tok = tok->next()->link();
if (Token::simpleMatch(tok, ") {"))
tok = tok->next()->link();
if (!tok) if (!tok)
{ {
ExecutionPath::bailOut(checks); ExecutionPath::bailOut(checks);

View File

@ -1209,6 +1209,14 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n"
"{\n"
" int c;\n"
" a = (f2(&c));\n"
" c++;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// += // +=
checkUninitVar("void f()\n" checkUninitVar("void f()\n"
"{\n" "{\n"