#6301 Unused shared lock variable. Add exception for std::shared_lock() to CheckUnusedVar::checkFunctionVariableUsage_iterateScopes()
This commit is contained in:
parent
d11eb4931a
commit
ec2c4aa2e3
|
@ -694,7 +694,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
i->typeEndToken()->isStandardType() ||
|
||||
isRecordTypeWithoutSideEffects(i->type()) ||
|
||||
(i->isStlType() &&
|
||||
!Token::Match(i->typeStartToken()->tokAt(2), "lock_guard|unique_lock|shared_ptr|unique_ptr|auto_ptr")))
|
||||
!Token::Match(i->typeStartToken()->tokAt(2), "lock_guard|unique_lock|shared_ptr|unique_ptr|auto_ptr|shared_lock")))
|
||||
type = Variables::standard;
|
||||
if (type == Variables::none || isPartOfClassStructUnion(i->typeStartToken()))
|
||||
continue;
|
||||
|
|
|
@ -1870,7 +1870,7 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar46() { // #5491/#5494
|
||||
void localvar46() { // #5491/#5494/#6301
|
||||
functionVariableUsage("int func() {\n"
|
||||
" int i = 0;\n"
|
||||
" int j{i};\n"
|
||||
|
@ -1884,6 +1884,11 @@ private:
|
|||
" return 0;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("int func() {\n"
|
||||
" std::shared_lock<std::shared_timed_mutex> lock( m );\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvaralias1() {
|
||||
|
|
Loading…
Reference in New Issue