diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index a3d3e7c72..4794d2ea1 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5176,6 +5176,11 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const // Try to evaluate the apparently more complex expression else if (check->isCPP()) { const Token *vartok = arguments[j]; + if (vartok->str() == ".") { + const Token* rml = nextAfterAstRightmostLeaf(vartok); + if (rml) + vartok = rml->previous(); + } while (vartok->isUnaryOp("&") || vartok->isUnaryOp("*")) vartok = vartok->astOperand1(); const Variable* var = vartok->variable(); diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index cf3291c99..a481110a0 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -129,6 +129,7 @@ private: TEST_CASE(initvar_nocopy1); // ticket #2474 TEST_CASE(initvar_nocopy2); // ticket #2484 TEST_CASE(initvar_nocopy3); // ticket #3611 + TEST_CASE(initvar_nocopy4); // ticket #9247 TEST_CASE(initvar_with_member_function_this); // ticket #4824 TEST_CASE(initvar_destructor); // No variables need to be initialized in a destructor @@ -1598,6 +1599,22 @@ private: ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) Member variable 'A::b' is not assigned in the copy constructor. Should it be copied?\n", errout.str()); } + void initvar_nocopy4() { // #9247 + check("struct S {\n" + " S(const S & s);\n" + " void S::Set(const T& val);\n" + " void S::Set(const U& val);\n" + " T t;\n" + "};\n" + "S::S(const S& s) {\n" + " Set(s.t);\n" + "}\n" + "void S::Set(const T& val) {\n" + " t = val;\n" + "}", /*inconclusive*/ true); + ASSERT_EQUALS("", errout.str()); + } + void initvar_with_member_function_this() { check("struct Foo {\n" " Foo(int m) { this->setMember(m); }\n"