Fixed #10547 (False positive: constVariable, buffer written by stream read)
This commit is contained in:
parent
c49d246303
commit
921f5c1818
|
@ -1525,8 +1525,13 @@ void CheckOther::checkConstPointer()
|
|||
if (!p->scope() || !p->scope()->function || p->scope()->function->isImplicitlyVirtual(true) || p->scope()->function->hasVirtualSpecifier())
|
||||
continue;
|
||||
}
|
||||
if (nonConstPointers.find(p) == nonConstPointers.end())
|
||||
if (nonConstPointers.find(p) == nonConstPointers.end()) {
|
||||
const Token *start = (p->isArgument()) ? p->scope()->bodyStart : p->nameToken()->next();
|
||||
const int indirect = p->isArray() ? p->dimensions().size() : 1;
|
||||
if (isVariableChanged(start, p->scope()->bodyEnd, indirect, p->declarationId(), false, mSettings, mTokenizer->isCPP()))
|
||||
continue;
|
||||
constVariableError(p, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
void CheckOther::constVariableError(const Variable *var, const Function *function)
|
||||
|
|
|
@ -2764,6 +2764,13 @@ private:
|
|||
" memcpy(data.buf, &a, sizeof(a));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #10547
|
||||
check("void foo(std::istream &istr) {\n"
|
||||
" unsigned char x[2];\n"
|
||||
" istr >> x[0];\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void switchRedundantAssignmentTest() {
|
||||
|
|
Loading…
Reference in New Issue