Fixed false positive #5578

This commit is contained in:
PKEuS 2014-03-18 13:44:27 +01:00
parent af161fc361
commit 3a4b7e5c07
2 changed files with 7 additions and 1 deletions

View File

@ -250,7 +250,7 @@ void CheckIO::checkFileUsage()
case Filepointer::POSITIONING:
if (f.mode == CLOSED)
useClosedFileError(tok);
else if (f.append_mode == Filepointer::APPEND && _settings->isEnabled("warning"))
else if (f.append_mode == Filepointer::APPEND && tok->str() != "fflush" && _settings->isEnabled("warning"))
seekOnAppendedFileError(tok);
break;
case Filepointer::READ:

View File

@ -550,6 +550,12 @@ private:
" fseek(f, 0, SEEK_SET);\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (warning) Repositioning operation performed on a file opened in append mode has no effect.\n", errout.str());
check("void foo() {\n"
" FILE* f = fopen(\"\", \"a\");\n"
" fflush(f);\n"
"}");
ASSERT_EQUALS("", errout.str()); // #5578
}
void fflushOnInputStream() {