Fixed #4385: lock_guard RAII throws unreadVariable
This commit is contained in:
parent
049c995c99
commit
498d03458f
|
@ -684,7 +684,11 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
type = Variables::pointerPointer;
|
||||
else if (i->isPointer())
|
||||
type = Variables::pointer;
|
||||
else if (_tokenizer->isC() || i->typeEndToken()->isStandardType() || isRecordTypeWithoutSideEffects(i->type()) || Token::simpleMatch(i->typeStartToken(), "std ::"))
|
||||
else if (_tokenizer->isC() ||
|
||||
i->typeEndToken()->isStandardType() ||
|
||||
isRecordTypeWithoutSideEffects(i->type()) ||
|
||||
(Token::simpleMatch(i->typeStartToken(), "std ::") &&
|
||||
i->typeStartToken()->strAt(2) != "lock_guard"))
|
||||
type = Variables::standard;
|
||||
if (type == Variables::none || isPartOfClassStructUnion(i->typeStartToken()))
|
||||
continue;
|
||||
|
|
|
@ -3512,6 +3512,11 @@ private:
|
|||
" std::vector<MyClass> x(100);\n" // Might have a side-effect
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("void f() {\n"
|
||||
" std::lock_guard<MyClass> lock(mutex_);\n" // Has a side-effect #4385
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// ticket #3104 - false positive when variable is read with "if (NOT var)"
|
||||
|
|
Loading…
Reference in New Issue