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:
Robert Reif 2014-04-10 17:25:11 +02:00 committed by Daniel Marjamäki
parent 42c8f73bd5
commit b0af67f369
2 changed files with 11 additions and 0 deletions

View File

@ -1139,6 +1139,10 @@ void CheckIO::checkWrongPrintfScanfArguments()
} else if (argInfo.typeToken->originalName() != "ptrdiff_t")
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);
break;
case 'z':
if (argInfo.typeToken->originalName() != "ssize_t")
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
break;
default:
if (!Token::Match(argInfo.typeToken, "bool|char|short|int"))
invalidPrintfArgTypeError_sint(tok, numFormat, specifier, &argInfo);

View File

@ -2735,6 +2735,13 @@ private:
"}\n");
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