File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -692,7 +692,8 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
692692 i->typeEndToken ()->isStandardType () ||
693693 isRecordTypeWithoutSideEffects (i->type ()) ||
694694 (Token::simpleMatch (i->typeStartToken (), " std ::" ) &&
695- i->typeStartToken ()->strAt (2 ) != " lock_guard" ))
695+ i->typeStartToken ()->strAt (2 ) != " lock_guard" &&
696+ i->typeStartToken ()->strAt (2 ) != " unique_lock" ))
696697 type = Variables::standard;
697698 if (type == Variables::none || isPartOfClassStructUnion (i->typeStartToken ()))
698699 continue ;
Original file line number Diff line number Diff line change @@ -3537,6 +3537,12 @@ class TestUnusedVar : public TestFixture {
35373537 " std::lock_guard<MyClass> lock(mutex_);\n " // Has a side-effect #4385
35383538 " }" );
35393539 ASSERT_EQUALS (" " , errout.str ());
3540+
3541+ functionVariableUsage (" void f() {\n "
3542+ " std::mutex m;\n "
3543+ " std::unique_lock<std::mutex> lock(m);\n " // #4624
3544+ " }" );
3545+ ASSERT_EQUALS (" " , errout.str ());
35403546 }
35413547
35423548 // ticket #3104 - false positive when variable is read with "if (NOT var)"
You can’t perform that action at this time.
0 commit comments