Fixed #8258 (Incorrect diagnostics when using delegating consturctor with default values) (#1255)

This commit is contained in:
IOBYTE 2018-05-22 00:42:37 -04:00 committed by Daniel Marjamäki
parent 01cbadc6ed
commit 8320be203d
2 changed files with 23 additions and 0 deletions

View File

@ -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()));

View File

@ -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());
}