Fixed #4040 (false positive: (error) Uninitialized variable: iter)
This commit is contained in:
parent
671f1b83d9
commit
0d82b08080
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue