Skip to content
Open
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: 0 additions & 4 deletions lib/checkunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,10 +1160,6 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
variables.read(tok2->varId(), tok);
}
}
} else if (tok->variable() && tok->variable()->isClass() && tok->variable()->type() &&
(tok->variable()->type()->needInitialization == Type::NeedInitialization::False) &&
tok->strAt(1) == ";") {
variables.write(tok->varId(), tok);
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions test/testunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7070,6 +7070,24 @@ class TestUnusedVar : public TestFixture {
" S<0> s;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:6:10]: (style) Unused variable: s [unusedVariable]\n", errout_str());

functionVariableUsage("template <typename T>\n" // #14783
"struct A {\n"
" A() = default;\n"
"};\n"
"void f() {\n"
" A<int> a;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:6:12]: (style) Unused variable: a [unusedVariable]\n", errout_str());

functionVariableUsage("template <typename T>\n" // #14784
"struct A {\n"
" A() {}\n"
"};\n"
"void f() {\n"
" A<int> a;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:6:12]: (style) Unused variable: a [unusedVariable]\n", errout_str());
}

void localvarFuncPtr() {
Expand Down Expand Up @@ -7158,6 +7176,7 @@ class TestUnusedVar : public TestFixture {
"void f() {\n"
" Y y;\n"
"}"); // #4695
ASSERT_EQUALS("[test.cpp:6:7]: (style) Unused variable: y [unusedVariable]\n", errout_str());
}

void crash3() {
Expand Down
Loading