diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 979cee670..4e6d96af8 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -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: diff --git a/test/testio.cpp b/test/testio.cpp index eafbdba73..b37e3b951 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -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() {