diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 80853ba6d..7fb9438a0 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3963,6 +3963,9 @@ static void checkVariableCallMatch(const Variable* callarg, const Variable* func static bool valueTypeMatch(const ValueType * valuetype, const Token * type) { + if (valuetype->typeScope && type->type() && type->type()->classScope == valuetype->typeScope) + return true; + return ((((type->str() == "bool" && valuetype->type == ValueType::BOOL) || (type->str() == "char" && valuetype->type == ValueType::CHAR) || (type->str() == "short" && valuetype->type == ValueType::SHORT) || @@ -5321,6 +5324,14 @@ void SymbolDatabase::setValueTypeInTokenList() setValueType(tok, valuetype); } + // constructor + else if (tok->previous() && tok->previous()->type() && tok->previous()->type()->classScope) { + ValueType valuetype; + valuetype.type = ValueType::RECORD; + valuetype.typeScope = tok->previous()->type()->classScope; + setValueType(tok, valuetype); + } + // library function else if (tok->previous()) { const std::string& typestr(_settings->library.returnValueType(tok->previous())); diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index ab37e7aac..d52a3fe1e 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -1098,6 +1098,18 @@ private: " A(float a) : A(int(a)) {}\n" "};"); ASSERT_EQUALS("", errout.str()); + + // Ticket #8258 + check("struct F{};\n" + "struct Foo {\n" + " Foo(int a, F&& f, int b = 21) : _a(a), _b(b), _f(f) {}\n" + " Foo(int x, const char* value) : Foo(x, F(), 42) {}\n" + " Foo(int x, int* value) : Foo(x, F()) {}\n" + " int _a;\n" + " int _b;\n" + " F _f;\n" + "};"); + ASSERT_EQUALS("", errout.str()); }