Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down Expand Up @@ -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()));
Expand Down
12 changes: 12 additions & 0 deletions test/testconstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,18 @@ class TestConstructors : public TestFixture {
" 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());
}


Expand Down