diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 00d6183ce..8f1cf536c 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -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()) { diff --git a/test/testio.cpp b/test/testio.cpp index 7003caef9..1d7332b3b 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -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() {