This commit is contained in:
parent
158f3d494e
commit
9d6e5c2a05
|
@ -5172,7 +5172,12 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
|
|||
const Token *vartok = arguments[j];
|
||||
while (vartok->isUnaryOp("&") || vartok->isUnaryOp("*"))
|
||||
vartok = vartok->astOperand1();
|
||||
ValueType::MatchResult res = ValueType::matchParameter(arguments[j]->valueType(), vartok->variable(), funcarg);
|
||||
const Variable* var = vartok->variable();
|
||||
// smart pointer deref?
|
||||
if (var && vartok->astParent() && vartok->astParent()->str() == "*" &&
|
||||
var->isSmartPointer() && var->valueType() && var->valueType()->smartPointerTypeToken)
|
||||
var = var->valueType()->smartPointerTypeToken->variable();
|
||||
ValueType::MatchResult res = ValueType::matchParameter(arguments[j]->valueType(), var, funcarg);
|
||||
if (res == ValueType::MatchResult::SAME)
|
||||
++same;
|
||||
else if (res == ValueType::MatchResult::FALLBACK1)
|
||||
|
|
|
@ -130,6 +130,7 @@ private:
|
|||
TEST_CASE(initvar_alias); // #6921
|
||||
|
||||
TEST_CASE(initvar_templateMember); // #7205
|
||||
TEST_CASE(initvar_smartptr); // #10237
|
||||
|
||||
TEST_CASE(operatorEqSTL);
|
||||
|
||||
|
@ -1686,6 +1687,24 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initvar_smartptr() { // #10237
|
||||
Settings s;
|
||||
s.libraries.emplace_back("std");
|
||||
check("struct S {\n"
|
||||
" explicit S(const std::shared_ptr<S>& sp) {\n"
|
||||
" set(*sp);\n"
|
||||
" }\n"
|
||||
" double get() const {\n"
|
||||
" return d;\n"
|
||||
" }\n"
|
||||
" void set(const S& rhs) {\n"
|
||||
" d = rhs.get();\n"
|
||||
" }\n"
|
||||
" double d;\n"
|
||||
"};", s);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void operatorEqSTL() {
|
||||
check("class Fred\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue