From fa968d75bdd84afb078818c53c0274fc51f24169 Mon Sep 17 00:00:00 2001 From: IOBYTE Date: Wed, 4 Apr 2018 02:29:12 -0400 Subject: [PATCH] Partial fix for #8291: (False positive uninitMemberVar when calling delegated constructor) (#1142) --- lib/symboldatabase.cpp | 2 +- test/testclass.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 4655582dd..868db7161 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5030,7 +5030,7 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V valuetype->type = ValueType::Type::INT; } else valuetype->type = ValueType::Type::RECORD; - while (Token::Match(type, "%name%|*|&|::") && !type->variable()) { + while (Token::Match(type, "%name%|*|&|::") && !type->variable() && !type->function()) { if (type->isSigned()) valuetype->sign = ValueType::Sign::SIGNED; else if (type->isUnsigned()) diff --git a/test/testclass.cpp b/test/testclass.cpp index 41865ae44..c804d77f2 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6208,6 +6208,15 @@ private: " char s;\n" "};"); ASSERT_EQUALS("", errout.str()); + + checkInitializationListUsage("unsigned bar(std::string);\n" // #8291 + "class Foo {\n" + "public:\n" + " int a_, b_;\n" + " Foo(int a, int b) : a_(a), b_(b) {}\n" + " Foo(int a, const std::string& b) : Foo(a, bar(b)) {}\n" + "};"); + ASSERT_EQUALS("", errout.str()); }