Fixed false positives on FILE* arrays. (#3965)

This commit is contained in:
PKEuS 2012-07-29 04:04:12 -07:00
parent 2f95b97c66
commit 6aa7f984cb
2 changed files with 8 additions and 1 deletions

View File

@ -102,7 +102,7 @@ void CheckIO::checkFileUsage()
std::size_t varListSize = symbolDatabase->getVariableListSize();
for (std::size_t i = 1; i < varListSize; ++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;
if (var->isLocal()) {

View File

@ -280,6 +280,13 @@ private:
" fwrite(buffer, 5, 6, f);\n"
"}");
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() {