Merge pull request #800 from simartin/ticket_7445

Ticket #7445: Properly represent integer types smaller than int in CheckIO::ArgumentInfo.
This commit is contained in:
Daniel Marjamäki 2016-05-28 19:52:20 +02:00
commit d0a1a3123c
2 changed files with 7 additions and 3 deletions

View File

@ -1389,9 +1389,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings,
tempToken->insertToken("a");
tempToken = tempToken->next();
}
if (valuetype->pointer == 0U && valuetype->type <= ValueType::INT)
tempToken->str("int");
else if (valuetype->type == ValueType::BOOL)
if (valuetype->type == ValueType::BOOL)
tempToken->str("bool");
else if (valuetype->type == ValueType::CHAR)
tempToken->str("char");

View File

@ -2187,6 +2187,12 @@ private:
ASSERT_EQUALS("[test.cpp:9]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'int'.\n"
"[test.cpp:9]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'float'.\n", errout.str());
// Ticket #7445
check("struct S { unsigned short x; } s = {0};\n"
"void foo() {\n"
" printf(\"%d\", s.x);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void testPosixPrintfScanfParameterPosition() { // #4900 - No support for parameters in format strings