Uninitialized variables; Fixed false positive for 'cin >> x[0]'
This commit is contained in:
parent
4b11bb4ad3
commit
0aebc32ae0
|
@ -1163,6 +1163,9 @@ const Token* CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer,
|
|||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (astIsRhs(derefValue) && isLikelyStreamRead(mTokenizer->isCPP(), derefValue->astParent()))
|
||||
return nullptr;
|
||||
|
||||
if (mTokenizer->isCPP() && Token::simpleMatch(valueExpr->astParent(), "&") && !valueExpr->astParent()->astParent() && astIsRhs(valueExpr) && Token::Match(valueExpr->astSibling(), "%type%"))
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -421,6 +421,12 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("void f() {\n"
|
||||
" int ret[2];\n"
|
||||
" std::cin >> ret[0];\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("void f(int i) {\n"
|
||||
" int a;\n"
|
||||
" i >> a;\n"
|
||||
|
|
Loading…
Reference in New Issue