From 1670805a8df4e44bcc15a65134f0c5581f1bc661 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 10 Jan 2022 07:43:02 +0100 Subject: [PATCH] Fix #10490 FP unreadVariable with std::shared_lock (#3672) --- cfg/std.cfg | 3 +++ test/testunusedvar.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/cfg/std.cfg b/cfg/std.cfg index 530abcad6..79c5257a9 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -8339,6 +8339,9 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init std::insert_iterator + std::lock_guard + std::unique_lock + std::shared_lock std::pair diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 5b2ad0751..9a93f9b0a 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -3051,6 +3051,16 @@ private: " std::shared_lock 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 { 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