Changed severity of fflushOnInputStream to portability: The behaviour of fflush(stdin) is defined on Linux.
This commit is contained in:
parent
e1bc5f5248
commit
b07f61170d
|
@ -176,7 +176,7 @@ void CheckIO::checkFileUsage()
|
||||||
operation = Filepointer::OPEN;
|
operation = Filepointer::OPEN;
|
||||||
} else if ((tok->str() == "rewind" || tok->str() == "fseek" || tok->str() == "fsetpos" || tok->str() == "fflush") ||
|
} else if ((tok->str() == "rewind" || tok->str() == "fseek" || tok->str() == "fsetpos" || tok->str() == "fflush") ||
|
||||||
(windows && tok->str() == "_fseeki64")) {
|
(windows && tok->str() == "_fseeki64")) {
|
||||||
if (Token::simpleMatch(tok, "fflush ( stdin )"))
|
if (_settings->isEnabled("portability") && Token::simpleMatch(tok, "fflush ( stdin )"))
|
||||||
fflushOnInputStreamError(tok, tok->strAt(2));
|
fflushOnInputStreamError(tok, tok->strAt(2));
|
||||||
else {
|
else {
|
||||||
fileTok = tok->tokAt(2);
|
fileTok = tok->tokAt(2);
|
||||||
|
@ -297,8 +297,8 @@ void CheckIO::checkFileUsage()
|
||||||
|
|
||||||
void CheckIO::fflushOnInputStreamError(const Token *tok, const std::string &varname)
|
void CheckIO::fflushOnInputStreamError(const Token *tok, const std::string &varname)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::error,
|
reportError(tok, Severity::portability,
|
||||||
"fflushOnInputStream", "fflush() called on input stream '" + varname + "' results in undefined behaviour.");
|
"fflushOnInputStream", "fflush() called on input stream '" + varname + "' may result in undefined behaviour on non-linux systems.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckIO::ioWithoutPositioningError(const Token *tok)
|
void CheckIO::ioWithoutPositioningError(const Token *tok)
|
||||||
|
|
|
@ -581,13 +581,13 @@ private:
|
||||||
check("void foo()\n"
|
check("void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" fflush(stdin);\n"
|
" fflush(stdin);\n"
|
||||||
"}");
|
"}", false, true);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) fflush() called on input stream 'stdin' results in undefined behaviour.\n", errout.str());
|
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"
|
check("void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" fflush(stdout);\n"
|
" fflush(stdout);\n"
|
||||||
"}");
|
"}", false, true);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue