Fixed #3335 (new check: warn about potential missuse of isgraph-like functions)
This commit is contained in:
parent
6d98406d71
commit
dd8316474a
|
@ -2209,7 +2209,7 @@ void CheckOther::checkCCTypeFunctions()
|
|||
{
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (tok->varId() == 0 &&
|
||||
Token::Match(tok, "isalnum|isalpha|iscntrl|isdigit|isgraph|islower|isprint|ispunct|isspace|isupper|isxdigit ( %num% )") &&
|
||||
Token::Match(tok, "isalnum|isalpha|iscntrl|isdigit|isgraph|islower|isprint|ispunct|isspace|isupper|isxdigit ( %num% ,|)") &&
|
||||
MathLib::isNegative(tok->strAt(2))) {
|
||||
cctypefunctionCallError(tok, tok->str(), tok->tokAt(2)->str());
|
||||
}
|
||||
|
|
|
@ -1166,6 +1166,10 @@ private:
|
|||
" std::cout << isxdigit(-61) << std::endl;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Passing value -61 to isxdigit() cause undefined behavior, which may lead to a crash\n", errout.str());
|
||||
check("void f() {\n"
|
||||
"std::isgraph(-10000, loc);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Passing value -10000 to isgraph() cause undefined behavior, which may lead to a crash\n", errout.str());
|
||||
|
||||
}
|
||||
void fflushOnInputStreamTest() {
|
||||
|
|
Loading…
Reference in New Issue