Merge pull request #690 from Dmitry-Me/supportTemporariesWhenCheckingMembersUsage

Fix FP for members of temporaries
This commit is contained in:
amai2012 2015-09-25 17:56:27 +02:00
commit 0f608b8a66
2 changed files with 20 additions and 0 deletions

View File

@ -1265,6 +1265,11 @@ void CheckUnusedVar::checkStructMemberUsage()
used = true;
break;
}
const Function* function = structVarTok->function();
if (function && function->retType && function->retType->name() == structname) {
used = true;
break;
}
}
if (!used) {

View File

@ -250,6 +250,21 @@ private:
" a->a;\n"
"}");
ASSERT_EQUALS("[test.cpp:7]: (style) struct member 'B::a' is never used.\n", errout.str());
checkStructMemberUsage("struct A\n"
"{\n"
" int a;\n"
"};\n"
"struct B\n"
"{\n"
" int a;\n"
"};\n"
"A& bar();\n"
"void foo()\n"
"{\n"
" bar().a;\n"
"}");
ASSERT_EQUALS("[test.cpp:7]: (style) struct member 'B::a' is never used.\n", errout.str());
}
void structmember2() {