Fix FNs when various types are passed as %tu into printf

This commit is contained in:
Dmitry-Me 2017-11-15 22:40:16 +03:00
parent 4fc0a7998e
commit 167258a6bf
2 changed files with 8 additions and 4 deletions

View File

@ -1163,6 +1163,10 @@ void CheckIO::checkFormatString(const Token * const tok,
if (!typesMatch(argInfo.typeToken->originalName(), "size_t")) if (!typesMatch(argInfo.typeToken->originalName(), "size_t"))
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo); invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
break; break;
case 't':
if (!typesMatch(argInfo.typeToken->originalName(), "ptrdiff_t"))
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
break;
case 'I': case 'I':
if (specifier.find("I64") != std::string::npos) { if (specifier.find("I64") != std::string::npos) {
if (argInfo.typeToken->str() != "long" || !argInfo.typeToken->isLong()) if (argInfo.typeToken->str() != "long" || !argInfo.typeToken->isLong())

View File

@ -3741,14 +3741,14 @@ private:
TEST_PRINTF_WARN_AKA("%zx", "size_t", "std::intptr_t", "signed long", "signed long long"); TEST_PRINTF_WARN_AKA("%zx", "size_t", "std::intptr_t", "signed long", "signed long long");
TEST_PRINTF_WARN_AKA("%zx", "size_t", "std::uintptr_t", "unsigned long", "unsigned long long"); TEST_PRINTF_WARN_AKA("%zx", "size_t", "std::uintptr_t", "unsigned long", "unsigned long long");
//TODO TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "bool"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "bool");
TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "char"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "char");
TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed char"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed char");
//TODO TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "unsigned char"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "unsigned char");
TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed short"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed short");
//TODO TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "unsigned short"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "unsigned short");
TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed int"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed int");
//TODO TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "unsigned int"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "unsigned int");
TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed long"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed long");
TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "unsigned long"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "unsigned long");
TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed long long"); TEST_PRINTF_WARN("%tu", "unsigned ptrdiff_t", "signed long long");