diff --git a/lib/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 5ef468af7..5e2bc390f 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -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; diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 2b8ee0a7a..7eeafa8bf 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -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 lock( m );\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void localvaralias1() {