File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1160,10 +1160,6 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
11601160 variables.read (tok2->varId (), tok);
11611161 }
11621162 }
1163- } else if (tok->variable () && tok->variable ()->isClass () && tok->variable ()->type () &&
1164- (tok->variable ()->type ()->needInitialization == Type::NeedInitialization::False) &&
1165- tok->strAt (1 ) == " ;" ) {
1166- variables.write (tok->varId (), tok);
11671163 }
11681164 }
11691165}
Original file line number Diff line number Diff line change @@ -7070,6 +7070,15 @@ class TestUnusedVar : public TestFixture {
70707070 " S<0> s;\n "
70717071 " }\n " );
70727072 ASSERT_EQUALS (" [test.cpp:6:10]: (style) Unused variable: s [unusedVariable]\n " , errout_str ());
7073+
7074+ functionVariableUsage (" template <typename T>\n "
7075+ " struct A {\n "
7076+ " A() = default;\n "
7077+ " };\n "
7078+ " void f() {\n "
7079+ " A<int> a;\n "
7080+ " }\n " );
7081+ ASSERT_EQUALS (" [test.cpp:6:12]: (style) Unused variable: a [unusedVariable]\n " , errout_str ());
70737082 }
70747083
70757084 void localvarFuncPtr () {
@@ -7158,6 +7167,7 @@ class TestUnusedVar : public TestFixture {
71587167 " void f() {\n "
71597168 " Y y;\n "
71607169 " }" ); // #4695
7170+ ASSERT_EQUALS (" [test.cpp:6:7]: (style) Unused variable: y [unusedVariable]\n " , errout_str ());
71617171 }
71627172
71637173 void crash3 () {
You can’t perform that action at this time.
0 commit comments