Fixed #4040 (false positive: (error) Uninitialized variable: iter)

This commit is contained in:
Daniel Marjamäki 2012-08-27 15:48:21 +02:00
parent 671f1b83d9
commit 0d82b08080
2 changed files with 21 additions and 0 deletions

View File

@ -145,6 +145,11 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
return;
}
if (Token::simpleMatch(tok, "union {")) {
tok = tok->next()->link();
continue;
}
if (tok->str() == "}")
return;

View File

@ -558,6 +558,22 @@ private:
" return Range;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #4040 - False positive
checkUninitVar("int f(int x) {\n"
" int iter;\n"
" {\n"
" union\n"
" {\n"
" int asInt;\n"
" double asDouble;\n"
" };\n"
"\n"
" iter = x;\n"
" }\n"
" return 1 + iter;\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void uninitvar3() { // #3844