Fixed #5486 (false positive: (warning) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'ssize_t {aka long}'.)
This commit is contained in:
parent
42c8f73bd5
commit
b0af67f369
|
@ -1139,6 +1139,10 @@ void CheckIO::checkWrongPrintfScanfArguments()
|
||||||
} else if (argInfo.typeToken->originalName() != "ptrdiff_t")
|
} else if (argInfo.typeToken->originalName() != "ptrdiff_t")
|
||||||
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
||||||
break;
|
break;
|
||||||
|
case 'z':
|
||||||
|
if (argInfo.typeToken->originalName() != "ssize_t")
|
||||||
|
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (!Token::Match(argInfo.typeToken, "bool|char|short|int"))
|
if (!Token::Match(argInfo.typeToken, "bool|char|short|int"))
|
||||||
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
|
||||||
|
|
|
@ -2735,6 +2735,13 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #5486
|
||||||
|
check("void foo() {\n"
|
||||||
|
" ssize_t test = 0;\n"
|
||||||
|
" printf(\"%zd\", test);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void testPosixPrintfScanfParameterPosition() { // #4900 - No support for parameters in format strings
|
void testPosixPrintfScanfParameterPosition() { // #4900 - No support for parameters in format strings
|
||||||
|
|
Loading…
Reference in New Issue