Fixed #4717 (False positive: Uninitialized variable inside ({..}))

This commit is contained in:
Daniel Marjamäki 2013-04-09 17:02:11 +02:00
parent 1935c544e0
commit 4c8b17c040
2 changed files with 7 additions and 0 deletions

View File

@ -1084,6 +1084,8 @@ void CheckUninitVar::checkScope(const Scope* scope)
} }
while (tok && tok->str() != ";") while (tok && tok->str() != ";")
tok = tok->next(); tok = tok->next();
if (Token::findsimplematch(i->typeStartToken(), "=", tok))
continue;
if (stdtype || i->isPointer()) if (stdtype || i->isPointer())
checkScopeForVariable(scope, tok, *i, NULL, NULL, ""); checkScopeForVariable(scope, tok, *i, NULL, NULL, "");
if (Token::Match(i->typeStartToken(), "struct %type% %var% ;")) { if (Token::Match(i->typeStartToken(), "struct %type% %var% ;")) {

View File

@ -2350,6 +2350,11 @@ private:
" x((A)(B)&a);\n" " x((A)(B)&a);\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar2("void f() {\n" // #4717 - ({})
" int a = ({ long b = (long)(123); 2 + b; });\n"
"}", "test.c");
ASSERT_EQUALS("", errout.str());
} }
// #3869 - reference variable // #3869 - reference variable