Fix #10490 FP unreadVariable with std::shared_lock (#3672)

This commit is contained in:
chrchr-github 2022-01-10 07:43:02 +01:00 committed by GitHub
parent df3da38483
commit 1670805a8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -8339,6 +8339,9 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
<type-checks>
<unusedvar>
<suppress>std::insert_iterator</suppress>
<suppress>std::lock_guard</suppress>
<suppress>std::unique_lock</suppress>
<suppress>std::shared_lock</suppress>
<check>std::pair</check>
</unusedvar>
</type-checks>

View File

@ -3051,6 +3051,16 @@ private:
" std::shared_lock<std::shared_timed_mutex> lock( m );\n"
"}");
ASSERT_EQUALS("", errout.str());
functionVariableUsage("void f() {\n" // #10490
" std::shared_lock lock = GetLock();\n"
"}");
ASSERT_EQUALS("", errout.str());
functionVariableUsage("void f() {\n"
" auto&& g = std::lock_guard<std::mutex> { mutex };\n"
"}\n");
TODO_ASSERT_EQUALS("", "[test.cpp:2]: (style) Variable 'g' is assigned a value that is never used.\n", errout.str());
}
void localvar47() { // #6603