Fix FP for members of temporaries

This commit is contained in:
Dmitry-Me 2015-09-25 13:57:11 +03:00
parent da15efb3f6
commit 6304a4dddb
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() {