Fixed regression #4368.
This commit is contained in:
parent
0f1e150386
commit
578e582987
|
@ -255,6 +255,11 @@ void CheckIO::checkFileUsage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (std::map<unsigned int, Filepointer>::iterator i = filepointers.begin(); i != filepointers.end(); ++i) {
|
||||||
|
i->second.op_indent = 0;
|
||||||
|
i->second.mode = UNKNOWN;
|
||||||
|
i->second.lastOperation = Filepointer::UNKNOWN_OP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,43 @@ private:
|
||||||
" fclose(f[0]);\n"
|
" fclose(f[0]);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #4368: multiple functions
|
||||||
|
check("static FILE *fp = NULL;\n"
|
||||||
|
"\n"
|
||||||
|
"void close()\n"
|
||||||
|
"{\n"
|
||||||
|
" fclose(fp);\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"void dump()\n"
|
||||||
|
"{\n"
|
||||||
|
" if (fp == NULL) return;\n"
|
||||||
|
" fprintf(fp, \"Here's the output.\\n\");\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"int main()\n"
|
||||||
|
"{\n"
|
||||||
|
" fp = fopen(\"test.txt\", \"w\");\n"
|
||||||
|
" dump();\n"
|
||||||
|
" close();\n"
|
||||||
|
" return 0;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("static FILE *fp = NULL;\n"
|
||||||
|
"\n"
|
||||||
|
"void close()\n"
|
||||||
|
"{\n"
|
||||||
|
" fclose(fp);\n"
|
||||||
|
"}\n"
|
||||||
|
"\n"
|
||||||
|
"void dump()\n"
|
||||||
|
"{\n"
|
||||||
|
" fclose(fp);\n"
|
||||||
|
" fprintf(fp, \"Here's the output.\\n\");\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:11]: (error) Used file that is not opened.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void fileIOwithoutPositioning() {
|
void fileIOwithoutPositioning() {
|
||||||
|
|
Loading…
Reference in New Issue