Fix FN for signed short passed as %hx into printf
This commit is contained in:
parent
c6bf881ee6
commit
4ac56a55be
|
@ -996,7 +996,7 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
if (specifier[1] == 'h') {
|
if (specifier[1] == 'h') {
|
||||||
if (!(argInfo.typeToken->str() == "char" && argInfo.typeToken->isUnsigned()))
|
if (!(argInfo.typeToken->str() == "char" && argInfo.typeToken->isUnsigned()))
|
||||||
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
||||||
} else if (argInfo.typeToken->str() != "short")
|
} else if (!(argInfo.typeToken->str() == "short" && argInfo.typeToken->isUnsigned()))
|
||||||
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
invalidPrintfArgTypeError_uint(tok, numFormat, specifier, &argInfo);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
|
|
|
@ -3255,6 +3255,7 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (warning) %hx in format string (no. 1) requires 'unsigned short' but the argument type is 'char'.\n"
|
ASSERT_EQUALS("[test.cpp:2]: (warning) %hx in format string (no. 1) requires 'unsigned short' but the argument type is 'char'.\n"
|
||||||
"[test.cpp:2]: (warning) %hx in format string (no. 2) requires 'unsigned short' but the argument type is 'unsigned char'.\n"
|
"[test.cpp:2]: (warning) %hx in format string (no. 2) requires 'unsigned short' but the argument type is 'unsigned char'.\n"
|
||||||
|
"[test.cpp:2]: (warning) %hx in format string (no. 3) requires 'unsigned short' but the argument type is 'signed short'.\n"
|
||||||
"[test.cpp:2]: (warning) %hx in format string (no. 5) requires 'unsigned short' but the argument type is 'signed int'.\n"
|
"[test.cpp:2]: (warning) %hx in format string (no. 5) requires 'unsigned short' but the argument type is 'signed int'.\n"
|
||||||
"[test.cpp:2]: (warning) %hx in format string (no. 6) requires 'unsigned short' but the argument type is 'unsigned int'.\n"
|
"[test.cpp:2]: (warning) %hx in format string (no. 6) requires 'unsigned short' but the argument type is 'unsigned int'.\n"
|
||||||
"[test.cpp:2]: (warning) %hx in format string (no. 7) requires 'unsigned short' but the argument type is 'signed long'.\n"
|
"[test.cpp:2]: (warning) %hx in format string (no. 7) requires 'unsigned short' but the argument type is 'signed long'.\n"
|
||||||
|
@ -3496,7 +3497,7 @@ private:
|
||||||
TEST_PRINTF_WARN("%hx", "unsigned short", "char");
|
TEST_PRINTF_WARN("%hx", "unsigned short", "char");
|
||||||
TEST_PRINTF_WARN("%hx", "unsigned short", "signed char");
|
TEST_PRINTF_WARN("%hx", "unsigned short", "signed char");
|
||||||
TEST_PRINTF_WARN("%hx", "unsigned short", "unsigned char");
|
TEST_PRINTF_WARN("%hx", "unsigned short", "unsigned char");
|
||||||
//TODO TEST_PRINTF_WARN("%hx", "unsigned short", "signed short");
|
TEST_PRINTF_WARN("%hx", "unsigned short", "signed short");
|
||||||
TEST_PRINTF_NOWARN("%hx", "unsigned short", "unsigned short");
|
TEST_PRINTF_NOWARN("%hx", "unsigned short", "unsigned short");
|
||||||
TEST_PRINTF_WARN("%hx", "unsigned short", "signed int");
|
TEST_PRINTF_WARN("%hx", "unsigned short", "signed int");
|
||||||
TEST_PRINTF_WARN("%hx", "unsigned short", "unsigned int");
|
TEST_PRINTF_WARN("%hx", "unsigned short", "unsigned int");
|
||||||
|
|
Loading…
Reference in New Issue