Fix FP unusedVar with side effects in destructor (#4212)
This commit is contained in:
parent
6f5a5fd947
commit
6d22d6a8ae
|
@ -1535,7 +1535,7 @@ bool CheckUnusedVar::isRecordTypeWithoutSideEffects(const Type* type)
|
|||
|
||||
// Non-empty constructors => possible side effects
|
||||
for (const Function& f : type->classScope->functionList) {
|
||||
if (!f.isConstructor())
|
||||
if (!f.isConstructor() && !f.isDestructor())
|
||||
continue;
|
||||
if (f.argDef && Token::simpleMatch(f.argDef->link(), ") ="))
|
||||
continue; // ignore default/deleted constructors
|
||||
|
|
|
@ -536,6 +536,16 @@ private:
|
|||
" F f;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage(
|
||||
"struct S {\n"
|
||||
" static void f() { std::cout << \"f()\"; }\n"
|
||||
" ~S() { f(); }\n"
|
||||
"};\n"
|
||||
"void g() {\n"
|
||||
" S s;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void cleanFunction() {
|
||||
|
|
Loading…
Reference in New Issue