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; used = true;
break; break;
} }
const Function* function = structVarTok->function();
if (function && function->retType && function->retType->name() == structname) {
used = true;
break;
}
} }
if (!used) { if (!used) {

View File

@ -250,6 +250,21 @@ private:
" a->a;\n" " a->a;\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:7]: (style) struct member 'B::a' is never used.\n", errout.str()); 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() { void structmember2() {