diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 4d881457e..910c12445 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -176,7 +176,7 @@ void CheckIO::checkFileUsage() operation = Filepointer::OPEN; } else if ((tok->str() == "rewind" || tok->str() == "fseek" || tok->str() == "fsetpos" || tok->str() == "fflush") || (windows && tok->str() == "_fseeki64")) { - if (Token::simpleMatch(tok, "fflush ( stdin )")) + if (_settings->isEnabled("portability") && Token::simpleMatch(tok, "fflush ( stdin )")) fflushOnInputStreamError(tok, tok->strAt(2)); else { fileTok = tok->tokAt(2); @@ -297,8 +297,8 @@ void CheckIO::checkFileUsage() void CheckIO::fflushOnInputStreamError(const Token *tok, const std::string &varname) { - reportError(tok, Severity::error, - "fflushOnInputStream", "fflush() called on input stream '" + varname + "' results in undefined behaviour."); + reportError(tok, Severity::portability, + "fflushOnInputStream", "fflush() called on input stream '" + varname + "' may result in undefined behaviour on non-linux systems."); } void CheckIO::ioWithoutPositioningError(const Token *tok) diff --git a/test/testio.cpp b/test/testio.cpp index 9348bff41..a597e2cb5 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -581,13 +581,13 @@ private: check("void foo()\n" "{\n" " fflush(stdin);\n" - "}"); - ASSERT_EQUALS("[test.cpp:3]: (error) fflush() called on input stream 'stdin' results in undefined behaviour.\n", errout.str()); + "}", false, true); + ASSERT_EQUALS("[test.cpp:3]: (portability) fflush() called on input stream 'stdin' may result in undefined behaviour on non-linux systems.\n", errout.str()); check("void foo()\n" "{\n" " fflush(stdout);\n" - "}"); + "}", false, true); ASSERT_EQUALS("", errout.str()); }