Fixed false positives on FILE* arrays. (#3965)
This commit is contained in:
parent
2f95b97c66
commit
6aa7f984cb
|
@ -102,7 +102,7 @@ void CheckIO::checkFileUsage()
|
||||||
std::size_t varListSize = symbolDatabase->getVariableListSize();
|
std::size_t varListSize = symbolDatabase->getVariableListSize();
|
||||||
for (std::size_t i = 1; i < varListSize; ++i) {
|
for (std::size_t i = 1; i < varListSize; ++i) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
const Variable* var = symbolDatabase->getVariableFromVarId(i);
|
||||||
if (!var || !var->varId() || !Token::simpleMatch(var->typeStartToken(), "FILE *"))
|
if (!var || !var->varId() || var->isArray() || !Token::simpleMatch(var->typeStartToken(), "FILE *"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (var->isLocal()) {
|
if (var->isLocal()) {
|
||||||
|
|
|
@ -280,6 +280,13 @@ private:
|
||||||
" fwrite(buffer, 5, 6, f);\n"
|
" fwrite(buffer, 5, 6, f);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void foo() {\n" // #3965
|
||||||
|
" FILE* f[3];\n"
|
||||||
|
" f[0] = fopen(name, mode);\n"
|
||||||
|
" fclose(f[0]);\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void fileIOwithoutPositioning() {
|
void fileIOwithoutPositioning() {
|
||||||
|
|
Loading…
Reference in New Issue