Uninitialized variables; Fixed FP in range based for loop
This commit is contained in:
parent
4322311482
commit
bde8b4316e
|
@ -1132,6 +1132,13 @@ const Token* CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// LHS in range for loop:
|
||||
if (Token::simpleMatch(valueExpr->astParent(), ":") &&
|
||||
astIsLhs(valueExpr) &&
|
||||
valueExpr->astParent()->astParent() &&
|
||||
Token::simpleMatch(valueExpr->astParent()->astParent()->previous(), "for ("))
|
||||
return nullptr;
|
||||
|
||||
// Stream read/write
|
||||
// FIXME this code is a hack!!
|
||||
if (mTokenizer->isCPP() && Token::Match(valueExpr->astParent(), "<<|>>")) {
|
||||
|
|
|
@ -4121,14 +4121,20 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar_rangeBasedFor() { // #7078
|
||||
checkUninitVar("void function(Entry& entry) {\n"
|
||||
void uninitvar_rangeBasedFor() {
|
||||
checkUninitVar("void function(Entry& entry) {\n" // #7078
|
||||
" for (auto* expr : entry.exprs) {\n"
|
||||
" expr->operate();\n"
|
||||
" expr->operate();\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("void f() {\n"
|
||||
" int *item;\n"
|
||||
" for (item: itemList) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar_static() { // #8734
|
||||
|
|
Loading…
Reference in New Issue