Fix incorrect warning with `%zi` in format string (#3437)
This commit is contained in:
parent
ccb31d8510
commit
cd5fa015c1
|
@ -1782,7 +1782,7 @@ void CheckIO::invalidScanfArgTypeError_int(const Token* tok, nonneg int numForma
|
|||
else
|
||||
errmsg << "intmax_t";
|
||||
} else if (specifier[0] == 'z') {
|
||||
if (specifier[1] == 'd')
|
||||
if (specifier[1] == 'd' || specifier[1] == 'i')
|
||||
errmsg << "ssize_t";
|
||||
else
|
||||
errmsg << "size_t";
|
||||
|
@ -1875,7 +1875,7 @@ static void printfFormatType(std::ostream& os, const std::string& specifier, boo
|
|||
else
|
||||
os << "intmax_t";
|
||||
} else if (specifier[0] == 'z') {
|
||||
if (specifier[1] == 'd')
|
||||
if (specifier[1] == 'd' || specifier[1] == 'i')
|
||||
os << "ssize_t";
|
||||
else
|
||||
os << "size_t";
|
||||
|
|
|
@ -1533,6 +1533,8 @@ private:
|
|||
TEST_SCANF_NOWARN("%zd", "ssize_t", "ssize_t");
|
||||
TEST_SCANF_WARN_AKA("%zd", "ssize_t", "ptrdiff_t", "signed long", "signed long long");
|
||||
|
||||
TEST_SCANF_WARN_AKA("%zi", "ssize_t", "size_t", "unsigned long", "unsigned long long");
|
||||
|
||||
TEST_SCANF_WARN("%tu", "unsigned ptrdiff_t", "bool");
|
||||
TEST_SCANF_WARN("%tu", "unsigned ptrdiff_t", "char");
|
||||
TEST_SCANF_WARN("%tu", "unsigned ptrdiff_t", "signed char");
|
||||
|
@ -3705,6 +3707,9 @@ private:
|
|||
TEST_PRINTF_WARN_AKA("%jx", "uintmax_t", "std::intptr_t", "signed long", "signed long long");
|
||||
TEST_PRINTF_WARN_AKA("%jx", "uintmax_t", "std::uintptr_t", "unsigned long", "unsigned long long");
|
||||
|
||||
TEST_PRINTF_WARN_AKA("%zd", "ssize_t", "size_t", "unsigned long", "unsigned long long");
|
||||
TEST_PRINTF_WARN_AKA("%zi", "ssize_t", "size_t", "unsigned long", "unsigned long long");
|
||||
|
||||
TEST_PRINTF_WARN("%zu", "size_t", "bool");
|
||||
TEST_PRINTF_WARN("%zu", "size_t", "char");
|
||||
TEST_PRINTF_WARN("%zu", "size_t", "signed char");
|
||||
|
|
Loading…
Reference in New Issue