Skip to content

Commit d55010c

Browse files
Fix #9247 FP uninitMemberVar (inconclusive) (#3765)
1 parent c74eeb6 commit d55010c

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5176,6 +5176,11 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
51765176
// Try to evaluate the apparently more complex expression
51775177
else if (check->isCPP()) {
51785178
const Token *vartok = arguments[j];
5179+
if (vartok->str() == ".") {
5180+
const Token* rml = nextAfterAstRightmostLeaf(vartok);
5181+
if (rml)
5182+
vartok = rml->previous();
5183+
}
51795184
while (vartok->isUnaryOp("&") || vartok->isUnaryOp("*"))
51805185
vartok = vartok->astOperand1();
51815186
const Variable* var = vartok->variable();

test/testconstructors.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class TestConstructors : public TestFixture {
129129
TEST_CASE(initvar_nocopy1); // ticket #2474
130130
TEST_CASE(initvar_nocopy2); // ticket #2484
131131
TEST_CASE(initvar_nocopy3); // ticket #3611
132+
TEST_CASE(initvar_nocopy4); // ticket #9247
132133
TEST_CASE(initvar_with_member_function_this); // ticket #4824
133134

134135
TEST_CASE(initvar_destructor); // No variables need to be initialized in a destructor
@@ -1598,6 +1599,22 @@ class TestConstructors : public TestFixture {
15981599
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());
15991600
}
16001601

1602+
void initvar_nocopy4() { // #9247
1603+
check("struct S {\n"
1604+
" S(const S & s);\n"
1605+
" void S::Set(const T& val);\n"
1606+
" void S::Set(const U& val);\n"
1607+
" T t;\n"
1608+
"};\n"
1609+
"S::S(const S& s) {\n"
1610+
" Set(s.t);\n"
1611+
"}\n"
1612+
"void S::Set(const T& val) {\n"
1613+
" t = val;\n"
1614+
"}", /*inconclusive*/ true);
1615+
ASSERT_EQUALS("", errout.str());
1616+
}
1617+
16011618
void initvar_with_member_function_this() {
16021619
check("struct Foo {\n"
16031620
" Foo(int m) { this->setMember(m); }\n"

0 commit comments

Comments
 (0)