uninitvar: fixed TODO assertion
This commit is contained in:
parent
56bc5536aa
commit
c29997b117
|
@ -1029,6 +1029,18 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al
|
|||
if (possibleParent && isLikelyStreamRead(mTokenizer->isCPP(), possibleParent))
|
||||
return false;
|
||||
}
|
||||
if (alloc == ARRAY && Token::simpleMatch(vartok->astParent(), "[")) {
|
||||
const Token *arrayValue = vartok;
|
||||
while (arrayValue->astParent() &&
|
||||
(Token::simpleMatch(arrayValue->astParent(), "[") || arrayValue->astParent()->isUnaryOp("*")) &&
|
||||
arrayValue == arrayValue->astParent()->astOperand1())
|
||||
arrayValue = arrayValue->astParent();
|
||||
if (Token::Match(arrayValue->astParent(), "[(,]")) {
|
||||
const int use = isFunctionParUsage(arrayValue, pointer, NO_ALLOC, indirect);
|
||||
if (use >= 0)
|
||||
return (use>0);
|
||||
}
|
||||
}
|
||||
if (Token::Match(possibleParent, "[(,]")) {
|
||||
if (unknown)
|
||||
return false; // TODO: output some info message?
|
||||
|
|
|
@ -1487,7 +1487,7 @@ private:
|
|||
" int a[10];\n"
|
||||
" f(a[0]);\n"
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Uninitialized variable: a\n", "", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
// Ticket #2320
|
||||
checkUninitVar("void foo() {\n"
|
||||
|
|
Loading…
Reference in New Issue