diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index be45b3765..17f1f94b8 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5227,6 +5227,7 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V if (vt->sign != ValueType::Sign::UNKNOWN_SIGN) valuetype->sign = vt->sign; valuetype->constness = vt->constness; + valuetype->originalTypeName = vt->originalTypeName; while (Token::Match(type, "%name%|*|&|::") && !type->variable()) type = type->next(); break; diff --git a/test/testio.cpp b/test/testio.cpp index 7d145ba86..33a7d7c6a 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -72,6 +72,7 @@ private: TEST_CASE(testReturnValueTypeStdLib); TEST_CASE(testPrintfTypeAlias1); + TEST_CASE(testPrintfAuto); // #8992 } void check(const char* code, bool inconclusive = false, bool portability = false, Settings::PlatformType platform = Settings::Unspecified) { @@ -4720,6 +4721,14 @@ private: "[test.cpp:8]: (warning) %f in format string (no. 3) requires 'double' but the argument type is 'const signed int *'.\n", errout.str()); } + void testPrintfAuto() { // #8992 + check("void f() {\n" + " auto s = sizeof(int);\n" + " printf(\"%zu\", s);\n" + " printf(\"%f\", s);\n" + "}\n", false, true); + ASSERT_EQUALS("[test.cpp:4]: (portability) %f in format string (no. 1) requires 'double' but the argument type is 'size_t {aka unsigned long}'.\n", errout.str()); + } }; REGISTER_TEST(TestIO)