Fixed #4624 (Wrong error for instances of std::unique_lock (variable is never used))
This commit is contained in:
parent
ed03e2c845
commit
ecafe7a129
|
@ -692,7 +692,8 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
i->typeEndToken()->isStandardType() ||
|
||||
isRecordTypeWithoutSideEffects(i->type()) ||
|
||||
(Token::simpleMatch(i->typeStartToken(), "std ::") &&
|
||||
i->typeStartToken()->strAt(2) != "lock_guard"))
|
||||
i->typeStartToken()->strAt(2) != "lock_guard" &&
|
||||
i->typeStartToken()->strAt(2) != "unique_lock"))
|
||||
type = Variables::standard;
|
||||
if (type == Variables::none || isPartOfClassStructUnion(i->typeStartToken()))
|
||||
continue;
|
||||
|
|
|
@ -3537,6 +3537,12 @@ private:
|
|||
" std::lock_guard<MyClass> lock(mutex_);\n" // Has a side-effect #4385
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("void f() {\n"
|
||||
" std::mutex m;\n"
|
||||
" std::unique_lock<std::mutex> lock(m);\n" // #4624
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// ticket #3104 - false positive when variable is read with "if (NOT var)"
|
||||
|
|
Loading…
Reference in New Issue