Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/checkunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,9 @@ void CheckUnusedVar::checkFunctionVariableUsage()
const bool isPointer = tok->valueType() && (tok->valueType()->pointer || tok->valueType()->type == ValueType::SMART_POINTER);

if (tok->isName()) {
if (isRaiiClass(tok->valueType(), tok->isCpp(), false))
if (isRaiiClass(tok->valueType(), tok->isCpp(), false) ||
(tok->valueType() && tok->valueType()->type == ValueType::RECORD &&
(!tok->valueType()->typeScope || !isRecordTypeWithoutSideEffects(tok->valueType()->typeScope->definedType))))
continue;
tok = tok->next();
}
Expand Down
7 changes: 7 additions & 0 deletions test/testunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class TestUnusedVar : public TestFixture {
TEST_CASE(localvar68);
TEST_CASE(localvar69);
TEST_CASE(localvar70);
TEST_CASE(localvar71);
TEST_CASE(localvarloops); // loops
TEST_CASE(localvaralias1);
TEST_CASE(localvaralias2); // ticket #1637
Expand Down Expand Up @@ -3906,6 +3907,12 @@ class TestUnusedVar : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void localvar71() {
functionVariableUsage("struct A { explicit A(int i); };\n" // #12363
"void f() { A a(0); }\n");
ASSERT_EQUALS("", errout_str());
}

void localvarloops() {
// loops
functionVariableUsage("void fun(int c) {\n"
Expand Down