From 12a298b9cda1b05747417b2f5e176f892fce1c23 Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sat, 28 May 2016 15:36:13 +0200 Subject: [PATCH] Ticket #7445: Properly represent integer types smaller than int in CheckIO::ArgumentInfo. --- lib/checkio.cpp | 4 +--- test/testio.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 1bdbba1b7..2df5633bb 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -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"); diff --git a/test/testio.cpp b/test/testio.cpp index a9216db12..2f0cf774c 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -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