Fixed #3231 (False positive: uninitialized variable '({...})')

This commit is contained in:
Daniel Marjamäki 2011-10-30 18:19:09 +01:00
parent 63937f592e
commit f7fe665b00
2 changed files with 18 additions and 1 deletions

View File

@ -473,7 +473,10 @@ private:
if (tok.varId()) {
// array variable passed as function parameter..
if (Token::Match(tok.previous(), "[(,] %var% [+-,)]")) {
use(checks, &tok);
if (Token::Match(tok.previous(), "( %var% ) ="))
ExecutionPath::bailOutVar(checks, tok.varId());
else
use(checks, &tok);
//use_array(checks, &tok);
return &tok;
}

View File

@ -973,6 +973,20 @@ private:
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #3231 - ({ switch .. })
checkUninitVar("void f() {\n"
" int a;\n"
" ({\n"
" switch(sizeof(int)) {\n"
" case 4:\n"
" default:\n"
" (a)=0;\n"
" break;\n"
" };\n"
" })\n"
"}");
ASSERT_EQUALS("", errout.str());
}
// arrays..