Fixed #5264 (Size specifier in printf functions is wrong for some types)
This commit is contained in:
parent
10ff45b54a
commit
cbe3862599
|
@ -1038,8 +1038,13 @@ void CheckIO::checkWrongPrintfScanfArguments()
|
|||
} else if (specifier.find("I32") != std::string::npos) {
|
||||
if (argInfo.typeToken->str() != "int" || argInfo.typeToken->isLong())
|
||||
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
||||
} else if (!(argInfo.typeToken->originalName() != "size_t" ||
|
||||
argInfo.typeToken->originalName() != "ptrdiff_t"))
|
||||
} else if (!(argInfo.typeToken->originalName() == "size_t" ||
|
||||
argInfo.typeToken->originalName() == "ptrdiff_t" ||
|
||||
argInfo.typeToken->originalName() == "WPARAM" ||
|
||||
argInfo.typeToken->originalName() == "UINT_PTR" ||
|
||||
argInfo.typeToken->originalName() == "LONG_PTR" ||
|
||||
argInfo.typeToken->originalName() == "LPARAM" ||
|
||||
argInfo.typeToken->originalName() == "LRESULT"))
|
||||
invalidPrintfArgTypeError_int(tok, numFormat, specifier, &argInfo);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -2205,6 +2205,18 @@ private:
|
|||
"[test.cpp:15]: (warning) 'I' in format string (no. 1) is a length modifier and cannot be used without a conversion specifier.\n"
|
||||
"[test.cpp:16]: (warning) 'I32' in format string (no. 1) is a length modifier and cannot be used without a conversion specifier.\n"
|
||||
"[test.cpp:17]: (warning) 'I64' in format string (no. 1) is a length modifier and cannot be used without a conversion specifier.\n", errout.str());
|
||||
|
||||
// ticket #5264
|
||||
check("void foo(LPARAM lp, WPARAM wp, LRESULT lr) {\n"
|
||||
" printf(\"%Ix %Ix %Ix\", lp, wp, lr);\n"
|
||||
"}\n", false, false, Settings::Win64);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(LPARAM lp, WPARAM wp, LRESULT lr) {\n"
|
||||
" printf(\"%Ix %Ix %Ix\", lp, wp, lr);\n"
|
||||
"}\n", false, false, Settings::Win32A);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
|
||||
void testMicrosoftScanfArgument() {
|
||||
|
|
Loading…
Reference in New Issue