File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1155,10 +1155,6 @@ void CheckUnusedVarImpl::checkFunctionVariableUsage_iterateScopes(const Scope* c
11551155 variables.read (tok2->varId (), tok);
11561156 }
11571157 }
1158- } else if (tok->variable () && tok->variable ()->isClass () && tok->variable ()->type () &&
1159- (tok->variable ()->type ()->needInitialization == Type::NeedInitialization::False) &&
1160- tok->strAt (1 ) == " ;" ) {
1161- variables.write (tok->varId (), tok);
11621158 }
11631159 }
11641160}
Original file line number Diff line number Diff line change @@ -7083,6 +7083,24 @@ class TestUnusedVar : public TestFixture {
70837083 " S<0> s;\n "
70847084 " }\n " );
70857085 ASSERT_EQUALS (" [test.cpp:6:10]: (style) Unused variable: s [unusedVariable]\n " , errout_str ());
7086+
7087+ functionVariableUsage (" template <typename T>\n " // #14783
7088+ " struct A {\n "
7089+ " A() = default;\n "
7090+ " };\n "
7091+ " void f() {\n "
7092+ " A<int> a;\n "
7093+ " }\n " );
7094+ ASSERT_EQUALS (" [test.cpp:6:12]: (style) Unused variable: a [unusedVariable]\n " , errout_str ());
7095+
7096+ functionVariableUsage (" template <typename T>\n " // #14784
7097+ " struct A {\n "
7098+ " A() {}\n "
7099+ " };\n "
7100+ " void f() {\n "
7101+ " A<int> a;\n "
7102+ " }\n " );
7103+ ASSERT_EQUALS (" [test.cpp:6:12]: (style) Unused variable: a [unusedVariable]\n " , errout_str ());
70867104 }
70877105
70887106 void localvarFuncPtr () {
@@ -7171,6 +7189,7 @@ class TestUnusedVar : public TestFixture {
71717189 " void f() {\n "
71727190 " Y y;\n "
71737191 " }" ); // #4695
7192+ ASSERT_EQUALS (" [test.cpp:6:7]: (style) Unused variable: y [unusedVariable]\n " , errout_str ());
71747193 }
71757194
71767195 void crash3 () {
You can’t perform that action at this time.
0 commit comments