Fixed #3231 (False positive: uninitialized variable '({...})')
This commit is contained in:
parent
63937f592e
commit
f7fe665b00
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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..
|
||||
|
|
Loading…
Reference in New Issue