This commit is contained in:
parent
171da2e6f9
commit
f429245da2
|
@ -6553,8 +6553,10 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
|
|||
}
|
||||
|
||||
else if (Token::simpleMatch(tok->previous(), "sizeof (")) {
|
||||
// TODO: use specified size_t type
|
||||
ValueType valuetype(ValueType::Sign::UNSIGNED, ValueType::Type::LONG, 0U);
|
||||
if (mSettings->platformType == cppcheck::Platform::Win64)
|
||||
valuetype.type = ValueType::Type::LONGLONG;
|
||||
|
||||
valuetype.originalTypeName = "size_t";
|
||||
setValueType(tok, valuetype);
|
||||
|
||||
|
|
|
@ -3300,6 +3300,12 @@ private:
|
|||
" printf(\"%f\", x.f(4.0));\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" printf(\"%lu\", sizeof(char));\n"
|
||||
"}\n", false, true, Settings::Win64);
|
||||
ASSERT_EQUALS("[test.cpp:2]: (portability) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'size_t {aka unsigned long long}'.\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void testPrintfArgumentVariables() {
|
||||
|
|
Loading…
Reference in New Issue